ViewRootImpl的连接时机
2021-12-24 13:29
85 查看
ActivityThread在使用handleResumeActivity方法调用了activity的onResume方法之后,就调用了
wm.addView(decor, LayoutParams)
wm其实是WindowManagerGlobal
所以调用了
WindowManagerGlobal.addView
里面创建了view root impl,并把decor view作为view root impl的子view。
所以,在onResume方法之前,一个view的最顶层都是decor view,之后就是view root impl了。
而在子线程中更改UI会报错是因为调用了view root impl的方法,所以在onResume执行之前,比如onCreate,在子线程中更改UI是没有问题的。因为没有View root impl.
override fun onCreate(savedInstanceState: Bundle?) { ...... thread { binding.view1.text = "fadfasdf" var parent = binding.view1.parent while (parent != null) { Log.d("Right", parent.javaClass.canonicalName) parent = parent.parent } } binding.view1.setOnClickListener{ var parent = binding.view1.parent while (parent != null) { Log.d("Right", parent.javaClass.canonicalName) parent = parent.parent } } }
androidx.constraintlayout.widget.ConstraintLayout androidx.appcompat.widget.ContentFrameLayout androidx.appcompat.widget.ActionBarOverlayLayout android.widget.FrameLayout android.widget.LinearLayout com.android.internal.policy.DecorView 点击时的: androidx.constraintlayout.widget.ConstraintLayout androidx.appcompat.widget.ContentFrameLayout androidx.appcompat.widget.ActionBarOverlayLayout android.widget.FrameLayout android.widget.LinearLayout com.android.internal.policy.DecorView android.view.ViewRootImpl
相关文章推荐
- 动画结束时dismiss掉popupwindow出错 at android.view.ViewRootImpl.drawAccessibilityFocusedDrawableIfNeeded
- ViewRootImpl和WMS交互顺序
- 剖析Activity、Window、ViewRootImpl和View之间的关系
- Android ViewRootImpl Choreographer SurfaceFlinger 学习笔记
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- 我们来看ViewRootImpl的构造函数
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a vi
- 在Root的手机上开启ViewServer,使得HierachyViewer能够连接
- Android View源码解读:浅谈DecorView与ViewRootImpl
- android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original
- 我们来看ViewRootImpl的构造函数
- 如何在Root的手机上开启ViewServer,使得HierachyViewer能够连接(转)
- 如何在Root的手机上开启ViewServer,使得HierachyViewer能够连接
- 如何在Root的手机上开启ViewServer,使得HierachyViewer能够连接
- ViewRootImpl 传递整个绘制过程
- ViewRootImpl和WindowManagerService笔记
- ViewRootImpl、Surface、SurfaceFlinger简介
- Android异常:android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original
- Android View源码解读:浅谈DecorView与ViewRootImpl
- 网络验证更新组件报NetworkOnMainThreadException和ViewRootImpl$CalledFromWrongThreadException