merge with include optimize the Android layout , the effect is not known, the use of personal feeling also has a lot of limitations, but still understand, recorded.
Layout files have root nodes, but excessive nesting in Android can cause performance problems, so when you use include nesting we use the 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 ">
<textview
android:layout_width=" wrap_content "
android:layout_height=" Wrap_content "
android:text= "John"/>
<textview
android:layout_width= "wrap_content"
android:layout_height = "Wrap_content"
android:text= "Dick"/>
<textview android:layout_width=
"Wrap_content"
android:layout_height= "Wrap_content"
android:text= "Harry"/>
</merge>
The above interface is automatically nested into the following file when it is 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:tex t= "@string/hello_world"/> <button android:id= "@+id/toggle" android:layout_width= "Wrap_content" Android:layo
ut_height= "Wrap_content" android:onclick= "OnClick" android:text= "Show/Hide"/> <viewstub android: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 relatively big? Because the use of the space display in the merge will be displayed in the main layout file, such as my main layout is linearlayout and horizontal arrangement, then the elements in the merge are displayed in the horizontal arrangement, but if I want to let the elements of the merge vertical arrangement? Sorry, I can't do that.
Original link: http://blog.csdn.net/u012702547/article/details/47133647
This is the entire content of this article, I hope to learn more about Android software programming help.