View draw mechanism and Viewdraw Mechanism

Source: Internet
Author: User

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 ();}}

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.