1.performLayout():执行控件树布局
2.mView.gatherTransparentRegion():在控件树布局完成后,如果控件树中存在SurfaceView,则需要计算窗口的透明区域
布局控件树:
调用performLayout(),这个方法内容比较简单,主要是一句:
//host为RootViewImpl的根View
host.layout(0, 0, host.getMeasuredWidth(), host.getMeasuredHeight());
这样就启动了这个控件树的布局流程。
layout()方法:
public void layout(int l, int t, int r, int b) {//传进来的是相对于父控件的坐标
int oldL = mLeft;
int oldT = mTop;
int oldB = mBottom;
int oldR = mRight;
//... ...
//设置mLeft、mTop、mBottom、mRight四个成员
boolean changed = isLayoutModeOptical(mParent) ?
setOpticalFrame(l, t, r, b) : setFrame(l, t, r, b);
if (changed || (mPrivateFlags & PFLAG_LAYOUT_REQUIRED) == PFLAG_LAYOUT_REQUIRED) {
//onLayout()是用于布局子控件的,所以如果不是ViewGroup则什么都不用做