Custom Controls (3): How the View is drawn

Source: Internet
Author: User

Custom UI controls inherit the subclass of the view class or view and overload some methods in the view class without overloading, but at least overloading OnDraw ().
category Method Description
Creation Constructors
Onfinishinflate () This method is called after view and all its child objects are imported from XML
Layout onmeasure (int, int) View calls this method to confirm the size of itself and all child objects
OnLayout (boolean, int, int, int, int, int, int) This method is called when view wants to allocate size and position for all child objects
onsizechanged (int, int, int, int) This method is called when the view size changes
Drawing OnDraw (Canvas) This method is called when the view wants to draw its contents.
Event processing OnKeyDown (int, keyevent) This method is called when a new keystroke event occurs
onKeyUp (int, keyevent) This method is called when a key-release event occurs
Onmotionevent (motionevent) This method is called when an action event (such as touch) occurs
Focus Onfocuschanged (boolean, int) This method is called when the view Gets or loses focus
Attaching Onattachedtowindow () This method is called when the view is attached to a form
Ondetachedfromwindow () This method is called when the view leaves its form

View Drawing process: Onattachedtowindow, Onmeasrue, onsizechanged, OnLayout, OnDraw
Activity in drawing view: The root node reference to the hierarchy tree passed through the Setcontentview () activity is activated and gets focus---Request root node calculation and drawing tree The ViewGroup combines its own effective space with the layoutparams of the sub-view requirements to lay out the child view and call the child View's draw () method to draw the

Custom Controls (3): How the View is drawn

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.