mMainHandler.postDelayed({
Log.i("yang","<-------requestLayout------->")// 请求重新布局
mView?.requestLayout()},2000)// log 2024-06-0908:42:24.0814438-4438 yang I <-------requestLayout------->2024-06-0908:42:24.0894438-4438 Yang D MyView onMeasure
2024-06-0908:42:24.0894438-4438 Yang D MyLinearLayout onMeasure
2024-06-0908:42:24.0894438-4438 Yang D MyView onLayout
2024-06-0908:42:24.0894438-4438 Yang D MyLinearLayout onLayout
2024-06-0908:42:24.0894438-4438 Yang D MyLinearLayout onDraw
2024-06-0908:42:24.0894438-4438 Yang D MyView onDraw
修改View的布局参数
mMainHandler.postDelayed({
Log.i("yang","<-------requestLayout------->")
mView?.updateView()},2000)// log2024-06-0908:50:21.3734943-4943 yang I <-------requestLayout------->2024-06-0908:50:21.3764943-4943 Yang D MyView onMeasure
2024-06-0908:50:21.3764943-4943 Yang D MyLinearLayout onMeasure
2024-06-0908:50:21.3764943-4943 Yang D MyView onLayout
2024-06-0908:50:21.3764943-4943 Yang D MyButton onLayout
2024-06-0908:50:21.3764943-4943 Yang D MyLinearLayout onLayout
2024-06-0908:50:21.3774943-4943 Yang D MyLinearLayout onDraw
2024-06-0908:50:21.3774943-4943 Yang D MyView onDraw
2024-06-0908:50:21.3844943-4943 Yang D MyView onDraw
mMainHandler.postDelayed({
Log.i("yang","<-------forceLayout------->")
mView?.updateView()},2000)// log2024-06-0908:57:53.7325625-5625 yang I <-------forceLayout------->2024-06-0908:57:53.7415625-5625 Yang D MyView onMeasure
2024-06-0908:57:53.7415625-5625 Yang D MyLinearLayout onMeasure
2024-06-0908:57:53.7415625-5625 Yang D MyView onLayout
2024-06-0908:57:53.7415625-5625 Yang D MyButton onLayout
2024-06-0908:57:53.7415625-5625 Yang D MyLinearLayout onLayout
2024-06-0908:57:53.7415625-5625 Yang D MyLinearLayout onDraw
2024-06-0908:57:53.7425625-5625 Yang D MyView onDraw
2024-06-0908:57:53.7485625-5625 Yang D MyView onDraw