@@ -53,12 +53,24 @@ attributes of the included layout. The above example shows that you can use
5353layout; it will also override the id of the included layout if one is defined.
5454Similarly, you can override all the layout parameters. This means that any
5555<code>android:layout_*</code> attribute can be used with the <code><include
56- /></code> tag. Here is an example:</p>
56+ /></code> tag. Here is an example in
57+ which the same layout is included twice, but only the first one overrides the layout properties:</p>
5758
58- <pre class="prettyprint"><include android:layout_width="fill_parent" layout="@layout/image_holder" />
59- <include android:layout_width="256dip" layout="@layout/image_holder" />
59+ <pre>
60+ <!-- override the layout height and width -->
61+ <include layout="@layout/image_holder"
62+ android:layout_height="fill_parent"
63+ android:layout_width="fill_parent" />
64+ <!-- do not override layout dimensions; inherit them from image_holder -->
65+ <include layout="@layout/image_holder" />
6066</pre>
6167
68+ <p class="caution"><strong>Caution:</strong> If you want to override the layout dimensions,
69+ you must override both <code>android:layout_height</code> and
70+ <code>android:layout_width</code>—you cannot override only the height or only the width.
71+ If you override only one, it will not take effect. (Other layout properties, such as weight,
72+ are still inherited from the source layout.)</p>
73+
6274<p>This tag is particularly useful when you need to customize only part of your
6375UI depending on the device's configuration. For instance, the main layout of
6476your activity can be placed in the <code>layout/</code> directory and can
0 commit comments