summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/html/guide/topics/resources/layout-resource.jd10
-rw-r--r--docs/html/resources/articles/layout-tricks-reuse.jd18
2 files changed, 23 insertions, 5 deletions
diff --git a/docs/html/guide/topics/resources/layout-resource.jd b/docs/html/guide/topics/resources/layout-resource.jd
index 111851c..36369d3 100644
--- a/docs/html/guide/topics/resources/layout-resource.jd
+++ b/docs/html/guide/topics/resources/layout-resource.jd
@@ -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>&lt;include&gt;</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>&mdash;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
diff --git a/docs/html/resources/articles/layout-tricks-reuse.jd b/docs/html/resources/articles/layout-tricks-reuse.jd
index 072ba89..396e212 100644
--- a/docs/html/resources/articles/layout-tricks-reuse.jd
+++ b/docs/html/resources/articles/layout-tricks-reuse.jd
@@ -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>&lt;include
-/&gt;</code> tag. Here is an example:</p>
+/&gt;</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">&lt;include android:layout_width="fill_parent" layout="@layout/image_holder" /&gt;
-&lt;include android:layout_width="256dip" layout="@layout/image_holder" /&gt;
+<pre>
+&lt;!-- override the layout height and width --&gt;
+&lt;include layout="@layout/image_holder"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent" /&gt;
+&lt;!-- do not override layout dimensions; inherit them from image_holder --&gt;
+&lt;include layout="@layout/image_holder" /&gt;
</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>&mdash;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