View draw mechanism and Viewdraw Mechanism
View:
1. draw
// Draw a View and its subview. It is best not to override this method. You should override the onDraw method to draw your own.
Public void draw (Canvas canvas );
Public void draw (Canvas canvas) {1. draw backgroud (drawBackground); 2. Save the canvas layer to prepare fading; 3. Draw the content of the view (onDraw method); 4. Draw the children (dispatchDraw method); 5. If necessary, draw the fading edges and then restore the layer; 6. Draw the decorator, such as scrollBar (onDrawForeground );}
2. onDraw
// Draw the appearance of a View. The default Implementation of View is empty, so no source code is provided here.
Protected void onDraw (Canvas canvas );
ViewGroup:
1. dispatchDraw
/** Draw a sub-View. The View class is empty implement, and the ViewGroup class has implement */
Protected void dispatchDraw (Canvas canvas );
Protected void dispatchDraw (Canvas canvas) {if (layout animation to be drawn) {for (traversing sub-View) {binding layout animation;} start the animation control and notify the animation to start ;} for (traversing sub-View) {child. draw ();}}