view & viewGroup 调用顺序

View onMeasure:0&&0
View onMeasure:0&&0
ViewGroup onMeasure:0&&0


View onMeasure:0&&0
View onMeasure:0&&0
ViewGroup onMeasure:0&&0


ViewGroup onSizeChanged:100&&100
View onSizeChanged:0&&19
View onLayout:0&&19
View onSizeChanged:0&&19
View onLayout:0&&19


ViewGroup onLayout:100&&100
View onMeasure:0&&19
View onMeasure:0&&19


ViewGroup onMeasure:100&&100
View onMeasure:0&&19
View onMeasure:0&&19


ViewGroup onMeasure:100&&100
View onLayout:0&&19
View onLayout:0&&19


ViewGroup onLayout:100&&100


ViewGroup drawChild

ViewGroup drawChild

一、ViewGroup/View的绘制流程

简单的说一个View从无到有需要三个步骤,onMeasure、onLayout、onDraw,即测量大小、放置位置、绘制三个步骤。而ViewGroup的onMeasure、onLayout流程里,又会遍历每个孩子,并最终调到孩子的measure()、layout()函数里。与View不同的是,ViewGroup没有onDraw流程,但有dispatchDraw()流程,该函数最终又调用drawChild()绘制每个孩子,调每个孩子View的onDraw流程。

在onMeasure里可以直接setMeasuredDimension(measuredWidth, measuredHeight)设置控件宽和高,这样不管xml里咋写的,最终以此句设置的width和height进行放置、显示。

http://blog.csdn.net/yanzi1225627/article/details/30763555

http://blog.csdn.net/yanzi1225627/article/details/38147205

你可能感兴趣的:(view & viewGroup 调用顺序)