In everyday XML layouts we often use the <include/> tags to reuse some layout layouts, but in some cases some reuse layout is rarely used (or, in other words, rarely shown). Use <viewstub in this case /> Label overrides <include/> tags so that the seldom-used layout is not loaded into the main layout file, saving load time and overhead, When we need to use this layout, we can directly call the inflate () method in viewstub to display the layout file of the reuse.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/06/wKiom1Sn9vbwe5cyAADCcdzGUCE480.jpg "title=" 1.png " alt= "Wkiom1sn9vbwe5cyaadccdzguce480.jpg"/>
Using the Viewstub property is actually very simple, and the code snippet in the XML layout is as follows.
<viewstub android:id= "@+id/stub" android:inflatedid= "@+id/subtree" android:layout= "@layout/view_stu B_test "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "/>
Explain a few 2 properties:
android:layout= "@layout/view_stub_test"
This property, like the Layout property in the <include/> tag, indicates the layout of the fill.
Android:inflatedid= "@+id/subtree"
This property is actually a renaming of the filled layout layouts.
If you need to use the filled layout layouts (that is, view_stub_test) in your code, simply call the following
Viewstub = (viewstub) Findviewbyid (r.id.stub); Viewstub.inflate ();
Android's Viewstub