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