Open Sogrey opened 3 years ago
// ViewRootImpl.setView public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView) { requestLayout(); // ... // 这里的 view 是 DecorView view.assignParent(this); }
接着上面的代码看,在 ViewRootImpl.setView 里,通过 DecorView.assignParent 把 ViewRootImpl 设置为 DecorView 的 parent。
ViewRootImpl.setView
DecorView.assignParent
ViewRootImpl
DecorView
parent
所以 ViewRootImpl 和 DecorView 的关系就是 ViewRootImpl 是 DecorView 的 parent。
因为 DecorView 是我们布局的顶层,现在我们就知道层层调用requestLayout 等方法是怎么调用到 ViewRootImpl 里的了。
requestLayout
接着上面的代码看,在
ViewRootImpl.setView
里,通过DecorView.assignParent
把ViewRootImpl
设置为DecorView
的parent
。所以
ViewRootImpl
和DecorView
的关系就是ViewRootImpl
是DecorView
的parent
。因为
DecorView
是我们布局的顶层,现在我们就知道层层调用requestLayout
等方法是怎么调用到ViewRootImpl
里的了。