从ViewRootImpl的performTraverals方法开始,三步走
1.performMeasure调用view的Measure方法;
2.performLayout调用view的Layout方法;
3.performDraw调用view的draw方法;
View的测量:
1.measure(int widthMeasureSpec ,int heightMeasureSpec)------------------widthMeasureSpec是根据父控件的MeasureSpec和自身的布局参数计算出来的自身的MeasureSpec
2.onMeasure(int widthMeasureSpec ,int heightMeasureSpec)
3.setMeasuredDimeasion(int measureWidt,int measureHeight)
4.setMeasuredDimeasionRaw(int measureWidt,int measureHeight)-------设置view的mMeasureWidth和mMeasureHeight
ViewGroup的测量:
因为ViewGroup继承View所以,ViewGroup的测量过程和View一样:
1.measure
2.onMeasure----------------------------------不同点在于,ViewGroup没有自己的onMeasure,所以ViewGroup的子类一般会重写View的onMeasure方法,并给子View迭代测量;
3.setMeasuredDimeasion
4.setMeasuredDimeasionRaw