1. Minimize nesting levels of layouts
You can use the Hierarchyviewer tool provided by the SDK to analyze the view tree to help us discover unused layouts.
2, do not set unnecessary background, avoid excessive drawing
For example, if the parent control sets the background color and the child controls completely overwrite the parent control, then the parent control does not need to set the background.
3. Reuse the same layout code with <include> tags
4. Use <merge> tags to reduce the view hierarchy
There are two main uses of this tag:
1) because the root node of all Activity views is framelayout, so if our custom layout is also
Fragmenlayout, you can use merge instead.
2) when an Include or viewstub tag is imported from an external XML structure, the XML being imported can be used as the root section of the merge
Point, so that when it is embedded in the parent structure, it is good to dissolve the subset it contains into the parent structure without the redundant nodes.
<merge> can only be the root element of an XML layout.
5, through the <ViewStub> implementation of View delay loading
What are the optimization measures for the layout in Android?