From 3577f51d4bc236a11e283855337752a7b6897f8b Mon Sep 17 00:00:00 2001 From: Scott Main Date: Wed, 24 Nov 2010 11:24:33 -0800 Subject: docs: clarify layout properties bug: 3227820 Change-Id: Id5130cd805ee2ea545a795019fb375ffd841727f --- docs/html/guide/topics/resources/layout-resource.jd | 10 ++++++++-- docs/html/resources/articles/layout-tricks-reuse.jd | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) (limited to 'docs') 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.
android:layout_height
Dimension or keyword. Overrides the height given to the root view in the -included layout. +included layout. Only effective if android:layout_width is also declared.
android:layout_width
Dimension or keyword. Overrides the width given to the root view in the -included layout. +included layout. Only effective if android:layout_height is also declared.

You can include any other layout attributes in the <include> that are supported by the root element in the included layout and they will override those defined in the root element.

+

Caution: If you want to override the layout dimensions, +you must override both android:layout_height and +android:layout_width—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.)

+

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 android:layout_* attribute can be used with the <include -/> tag. Here is an example:

+/> tag. Here is an example in +which the same layout is included twice, but only the first one overrides the layout properties:

-
<include android:layout_width="fill_parent" layout="@layout/image_holder" />
-<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" />
 
+

Caution: If you want to override the layout dimensions, +you must override both android:layout_height and +android:layout_width—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.)

+

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 layout/ directory and can -- cgit v1.1