標籤:android blog c http a art
/*
* Draw traversal performs several drawing steps which must be executed
* in the appropriate order:
*
* 1. Draw the background
* 2. If necessary, save the canvas‘ layers to prepare for fading
* 3. Draw view‘s content
* 4. Draw children
* 5. If necessary, draw the fading edges and restore layers
* 6. Draw decorations (scrollbars for instance)
*/
// Step 1, draw the background, if needed
// Step 3, draw the content
if (!dirtyOpaque) onDraw(canvas);
// Step 4, draw the children
dispatchDraw(canvas);
// Step 6, draw decorations (scrollbars)
onDrawScrollBars(canvas);
onDraw():When custom a view, overriding this method
measure(內部調用onMeasure)
layout(內部調用onLayout)
draw(內部調用ondraw)
處理組件的布局通常要重寫onMesure和onLayout這兩個方法
Reference:
http://blog.csdn.net/czh0766/article/details/5790295
http://blog.csdn.net/scorplopan/article/details/6302827