1,view是如何被添加到屏幕窗口上:
----》创建顶层布局容器 DecorView
----》在顶层布局中加载加载记错布局ViewGroup
----》将ContentView添加到基础布局中的FrameLayout中
setContentView() getWindow().setContentView() 了解getWindow() 是返回一个window抽象类,仅仅存在唯一实现类 phoneWindow
于是乎 查看phoneWindow类源码 在类中搜索 setcontentView() 方法 如下图




走到这里decorView已经创建完成 我们回到 phoneWindow installDecor()方法





网友评论