Original: https://blog.csdn.net/SEU_Calvin/article/details/72855537
I think it is well written, there are several methods I have used before, but only used
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
0. Constructor
In addition to the constructor, there is also the corresponding attr information for reading the project
1.onFinsihInflate
The call triggered when the view and its xml file are loaded
2.onVisbilityChanged
When the visibility of the current view and the superior view changes, it is called
3.onAttachedTowindow
Fired when a view is attached to a window, called after onResume
4.onMeasure
Measure the size of the view
5.onsizechanged
Called after the measure method and when the measured size is different from before
6.onLayout
Called when assigning a position to a child view
7.ondraw
Render the content of this view
8.onWindowFoucusChanged
This method may also be called during the drawing process, specifically when the Window containing the current View gets or loses focus. At this point, some LayoutParameters of the View defined in the code can be set.
If the View enters the destruction phase, it will definitely be called.
9.onWindowVisibilityChanged
This method is the same as above, specifically, it is called when the visibility of the Window containing the current View changes.
10.onDetachedFromWindow
Triggered when the View leaves the attached window, for example, when the Activity calls the onDestroy method, the View will leave the window. Compared with AttachedToWindow at the beginning, it will only be called once.
Summarize
After setContentView, the Activity will read the view from xml and initialize it. After the loading is complete, it will call onFinishInflate. When the Activity executes to onResume, the View will be added to the window and execute onAttachToWindow, and then execute onMeasure, onSizeChanged, onLayout, and onDraw operations , these methods will be affected by the refresh of the view and the life cycle of the Activity, resulting in multiple executions. Finally onDetachedFromWindow is called when the page is destroyed