* commit '93116f8fb171a3cf0e9b68b70e2b275a8b6a32f7': docs: clarify <include> layout properties bug: 3227820
This commit is contained in:
@@ -149,17 +149,23 @@ resource.</dd>
|
|||||||
</dd>
|
</dd>
|
||||||
<dt><code>android:layout_height</code></dt>
|
<dt><code>android:layout_height</code></dt>
|
||||||
<dd><em>Dimension or keyword</em>. Overrides the height given to the root view in the
|
<dd><em>Dimension or keyword</em>. Overrides the height given to the root view in the
|
||||||
included layout.
|
included layout. Only effective if <code>android:layout_width</code> is also declared.
|
||||||
</dd>
|
</dd>
|
||||||
<dt><code>android:layout_width</code></dt>
|
<dt><code>android:layout_width</code></dt>
|
||||||
<dd><em>Dimension or keyword</em>. Overrides the width given to the root view in the
|
<dd><em>Dimension or keyword</em>. Overrides the width given to the root view in the
|
||||||
included layout.
|
included layout. Only effective if <code>android:layout_height</code> is also declared.
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<p>You can include any other layout attributes in the <code><include></code> that are
|
<p>You can include any other layout attributes in the <code><include></code> that are
|
||||||
supported by the root element in the included layout and they will override those defined in the
|
supported by the root element in the included layout and they will override those defined in the
|
||||||
root element.</p>
|
root element.</p>
|
||||||
|
|
||||||
|
<p class="caution"><strong>Caution:</strong> If you want to override the layout dimensions,
|
||||||
|
you must override both <code>android:layout_height</code> and
|
||||||
|
<code>android:layout_width</code>—you cannot override only the height or only the width.
|
||||||
|
If you override only one, it will not take effect. (Other layout properties, such as weight,
|
||||||
|
are still inherited from the source layout.)</p>
|
||||||
|
|
||||||
<p>Another way to include a layout is to use {@link android.view.ViewStub}. It is a lightweight
|
<p>Another way to include a layout is to use {@link android.view.ViewStub}. It is a lightweight
|
||||||
View that consumes no layout space until you explicitly inflate it, at which point, it includes a
|
View that consumes no layout space until you explicitly inflate it, at which point, it includes a
|
||||||
layout file defined by its {@code android:layout} attribute. For more information about using {@link
|
layout file defined by its {@code android:layout} attribute. For more information about using {@link
|
||||||
|
|||||||
@@ -53,12 +53,24 @@ attributes of the included layout. The above example shows that you can use
|
|||||||
layout; it will also override the id of the included layout if one is defined.
|
layout; it will also override the id of the included layout if one is defined.
|
||||||
Similarly, you can override all the layout parameters. This means that any
|
Similarly, you can override all the layout parameters. This means that any
|
||||||
<code>android:layout_*</code> attribute can be used with the <code><include
|
<code>android:layout_*</code> attribute can be used with the <code><include
|
||||||
/></code> tag. Here is an example:</p>
|
/></code> tag. Here is an example in
|
||||||
|
which the same layout is included twice, but only the first one overrides the layout properties:</p>
|
||||||
|
|
||||||
<pre class="prettyprint"><include android:layout_width="fill_parent" layout="@layout/image_holder" />
|
<pre>
|
||||||
<include android:layout_width="256dip" layout="@layout/image_holder" />
|
<!-- override the layout height and width -->
|
||||||
|
<include layout="@layout/image_holder"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_width="fill_parent" />
|
||||||
|
<!-- do not override layout dimensions; inherit them from image_holder -->
|
||||||
|
<include layout="@layout/image_holder" />
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<p class="caution"><strong>Caution:</strong> If you want to override the layout dimensions,
|
||||||
|
you must override both <code>android:layout_height</code> and
|
||||||
|
<code>android:layout_width</code>—you cannot override only the height or only the width.
|
||||||
|
If you override only one, it will not take effect. (Other layout properties, such as weight,
|
||||||
|
are still inherited from the source layout.)</p>
|
||||||
|
|
||||||
<p>This tag is particularly useful when you need to customize only part of your
|
<p>This tag is particularly useful when you need to customize only part of your
|
||||||
UI depending on the device's configuration. For instance, the main layout of
|
UI depending on the device's configuration. For instance, the main layout of
|
||||||
your activity can be placed in the <code>layout/</code> directory and can
|
your activity can be placed in the <code>layout/</code> directory and can
|
||||||
|
|||||||
Reference in New Issue
Block a user