LinearLayout
onMeasure
1 |
|
measureVertical
1 | /** |
measurehorizontal
1 | /** |
onLayout
1 |
|
layoutVertical
1 | /** |
layoutHorizontal
1 | /** |
onDraw
1 | //ref android.R.styleable#LinearLayout_divider |
FrameLayout
onMeasure
1 | /** |
onLayout
1 | /** |
onDraw
Nothing to do
RelativeLayout
onMeasure
1 | /** |
onLayout
1 | /** |
onDraw
doNothing
总结
Measure递归的起点
1 | ViewRootImpl:performTraversals()->getRootMeasureSpec()->MeasureSpec.makeMeasureSpec() |
ViewRoorImpl:getRootMeasureSpec
1 | /** |
MeasureSpec:makeMeasureSpec
1 | /** |
测量常用方法
第一步是获取MeasureSpec
布局的第一步是getMeasureSpec,然后是onMeasure(),然后………..
让child去获取测量宽高
1 | //ViewGroup: |
和parent给的宽高信息进行综合考虑
1 | //View: |
生成最终的宽高信息
1 | //View: |
通知影响的children重新测量
存储最终的测量宽高值
1 | //View: |
layout之前
从getMeasureSpec到onMeasure,接下来是setFrame,然后才是onLayout,再是…..
1 | /** |
Draw与onDraw
Draw 是用来drawBackground and drawForeground(eg:滚动条)的
onDraw是用来drawContent的