转载请注明出处:http://blog.csdn.net/crazy1235/article/details/72633389
layout - 布局
确定View的最终宽高以及四个顶点的位置!
接着上一篇 View的绘制流程分析之二 – measure 往下分析layout过程!
在ViewRootImpl 中的performTraversals() 函数内部,执行performMeasure() 完毕之后,
// Ask host how big it wants to be
performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);
// ...
layoutRequested = true;
final boolean didLayout = layoutRequested && (!mStopped || mReportNextDraw);
boolean triggerGlobalLayoutListener = didLayout
|| mAttachInfo.mRecomputeGlobalAttributes;
if (didLayout) {
performLayout(lp, mWidth, mHeight); // 开始布局过程!
// ...
}
private void performLayout(WindowManager.LayoutParams lp, int desiredWindowWidth,
int desiredWindowHeight) {
// ...
final View host = mView;
try {
host.layout(0, 0, host.getMeasuredWidth(), host.getMeasuredHeight());
// ...
}
} finally {
}
}
host就是那个DecorView对象!
然后又走到了View中的 layout()方法!
public void layout(int l, int t, int r, int b) {
// ...
boolean changed = isLayoutModeOptical(mParent) ?
setOpticalFrame(l, t, r, b) : setFrame(l, t, r, b);
if (chan