源码解析之setContentView

分享一下我以前学习时做到PPT中的一部分。
不难看出其实设置布局是由PhoneWindow来完成的。
然而我们要记住DecorView:
包括:状态栏,标题栏,内容

phoneWindow -> DecorView 内部类
DecorView extends FrameLayout private View mNavigationGuard; private View mStatusGuard; … 进行draw()
PhoneWindow extends Window中会通过installDecor()进行绘图操作。
installDecor(){
mDecor.makeOptionalFitsSystemWindows();
mTitleView= (TextView)findViewById(com.androidinternal.R.id.title);
mActionBar…
mContentParent…
…
}
绘图过程其实比较复杂的大体上可以用如下图说明。
会通过ViewRoot,AMS来完成,有关ViewRoot网上有很多资料可以参考其他资料。

最终会把一些大小,位置会写入Surface输出到LCD中。
浙公网安备 33010602011771号