Method and process of Android custom view drawing (2)
The last "Introduction to Android custom view (I) paint, rect and canvas" talked about the most basic how to customize a view and some tool classes used by the view. The following describes the method and process of view rendering
03-15 01:28:53.111 30961-30961/com.myView I/--------MyView: MyView() 03-15 01:28:53.111 30961-30961/com.myView I/--------MyView: onFinishInflate() 03-15 01:28:53.210 30961-30961/com.myView I/--------MyView: onMeasure() 03-15 01:28:53.210 30961-30961/com.myView I/--------MyView: onMeasure() 03-15 01:28:53.520 30961-30961/com.myView I/--------MyView: onMeasure() 03-15 01:28:53.520 30961-30961/com.myView I/--------MyView: onMeasure() 03-15 01:28:53.520 30961-30961/com.myView I/--------MyView: onSizeChanged() 03-15 01:28:53.543 30961-30961/com.myView I/--------MyView: onDraw()
1. Myview() construction method, which is not explained, is bound to be called first.
Function: pass in context
2. Onfinishinflate() is triggered when all child controls in the view are mapped to XML
3. Onmeasure() is called when the view is placed in the parent container
Function: measure the size of the view. You can also modify the size of the view in the following ways
You can also get the width and height of the control in the following ways
4. Onsizechanged() is called when the control size changes. So initialization will be called once
Function: get the width and height of the control
5. OnDraw () finally draws graphics
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.