Merge with include to optimize Android layout, the effect is not known. There are also very large limitations in the use of personal feelings. It's just a little bit more. Record them.
Layout files have root nodes, but too many nesting of layouts in Android can cause performance problems, so when using include nesting we can use merge as the root node, which reduces layout nesting and increases the display rate.
<?xml version= "1.0" encoding= "Utf-8"?><merge xmlns:android="Http://schemas.android.com/apk/res/android" > <TextViewandroid:layout_width="Wrap_content"android:layout_height= "Wrap_content" Android:text="Zhang San" /> <TextViewandroid:layout_width="Wrap_content"android:layout_height ="Wrap_content"android:text="John Doe" /> <TextViewandroid:layout_width="Wrap_content"android:layout_height= "Wrap_content" Android:text="Harry" /> </Merge>
The above interface will be actively nested into the following files when displayed.
<linearlayout xmlns:android="Http://schemas.android.com/apk/res/android" Xmlns:tools="Http://schemas.android.com/tools"android:layout_width="Match_parent" android:layout_height="Match_parent"android:orientation="Horizontal" Tools:context="com.example.viewstub.MainActivity" > <include layout="@layout/top"/> <textview android:layout _width = "wrap_content" android:layout_height = "wrap_content" android:text = "@string/hello_world" /> <button android:id = "@+id/toggle" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:onclick = "OnClick" android:text =/> <viewstubandroid:id="@+id/vs"android:layout_margin="50DP" android:layout_width="Match_parent"android:layout_height="Match_parent" Android:inflatedid="@+id/inflated_id"android:layout="@layout/view_stub_ Layout " /> </linearlayout>
Why do I say this limitation is bigger? The use of the space display in the merge is displayed as a main layout file. For example, my main layout here is linearlayout and horizontally arranged, so the elements in the merge appear to be arranged horizontally, but I suppose I want to arrange the elements in the merge vertically. Sorry, I can't do that.
Android development merge with include optimized layout