* commit '93116f8fb171a3cf0e9b68b70e2b275a8b6a32f7': docs: clarify <include> layout properties bug: 3227820
This commit is contained in:
@@ -149,17 +149,23 @@ resource.</dd>
|
||||
</dd>
|
||||
<dt><code>android:layout_height</code></dt>
|
||||
<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>
|
||||
<dt><code>android:layout_width</code></dt>
|
||||
<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>
|
||||
</dl>
|
||||
<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
|
||||
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
|
||||
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
|
||||
|
||||
@@ -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.
|
||||
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> 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" />
|
||||
<include android:layout_width="256dip" layout="@layout/image_holder" />
|
||||
<pre>
|
||||
<!-- 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>
|
||||
|
||||
<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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user