1，Reduce the nested use of the layout. Deleting useless controls can be hierarchical.
Choose to use ViewGroup, such as RelativeLayout, and choose the LineaLayout layout if you can use LinearLayout in the layout. If you can use FrameLayout, try to use Fram as much as possible.ELayout tries to use frame layout as far as possible. Frame layout is the fastest layout in the five large layout. He does not need to calculate the size of the control. It only needs to cover one layer and one layer on one layer. Reduce the nesting level of the layout. When one layout is finished, try to use a layer of nesting.Effect.
2，When there is layout reuse, is it extracted, using < include> tag specifying the layout of multiplexing; < merge> tags, and ViewStub tags.
includeThe layout attribute specifies an external layout file, which does not need to duplicate the layout file in the code. Such
If include specifies the properties of other android:layout_*, then layou_width and Layout_height must exist. Otherwise, others can’t take effect.
More with < include> tagging together to reduce the level of layout: if the current layout is a vertical LinearLayout, this time is also used as a vertical layout in the contained layout file, as in the contained layout file.We can use Merge tags to reduce nesting levels of layouts.
Inherited from View, he is very light weight and wide height 0, so he himself does not participate in any layout and rendering process.
Its significance is to load the required layout files as required. In the actual development, there are a lot of layout files that do not need to be displayed in normal circumstances and will be displayed when they need to be displayed. For example, the layout of network loading animation, it is not necessary to load it when the whole interface is initialized at this time.ViewStub can be loaded again when it is used. The performance of the program is improved.
<ViewStub android:id="@+id/stub_import" android:inflatedId="@+id/panel_import" android:layout="@layout/layout_network_error" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gavity="bottom" />
Load code on demand:((ViewStub) findViewById (R.id.stub_import)).SetVisibility (View.VISIBLE);Or:View importPanEl = ((ViewStub) findViewById (R.id.stub_import)).Inflate ();