参考
http://blog.csdn.net/luoshengyang/article/details/8372924
总体步骤 performTraversals-->measure---->layout----->draw 测量布局渲染
1.measure 测量过程
例子:FrameLayout
measure
测量开始判读是否需要测量
onMeasure
求实际宽度 measureChild调用子布局的 measure方法测量子布局大小,setMeasuredDimension,resolveSize设置布局大小
public static int resolveSize(int size, int measureSpec) { int result = size; int specMode = MeasureSpec.getMode(measureSpec); int specSize = MeasureSpec.getSize(measureSpec); switch (specMode) { case MeasureSpec.UNSPECIFIED: result = size; break; case MeasureSpec.AT_MOST: result = Math.min(size, specSize); break; case MeasureSpec.EXACTLY: result = specSize; break; } return result; }
2.layout
layout
onlayout
child.layout
3.draw
draw
draw blackgroud
onDraw
dispatchDraw
drawChild