diff --git a/docs/html/guide/practices/ui_guidelines/widget_design.jd b/docs/html/guide/practices/ui_guidelines/widget_design.jd index de20e007f3931..f63f3c4a8a763 100644 --- a/docs/html/guide/practices/ui_guidelines/widget_design.jd +++ b/docs/html/guide/practices/ui_guidelines/widget_design.jd @@ -250,13 +250,15 @@ android.widget.FrameLayout}. Just as your activity layouts must adapt to differe sizes, widget layouts must adapt to different Home screen grid cell sizes.

Below is an example layout that a music widget showing text information and two buttons can use. -It builds upon the previous discussion of adding margins depending on OS version.

+It builds upon the previous discussion of adding margins depending on OS version. Note that the +most robust and resilient way to add margins to the widget is to wrap the widget frame and contents +in a padded {@link android.widget.FrameLayout}.

 <FrameLayout
   android:layout_width="match_parent"
   android:layout_height="match_parent"
-  android:layout_margin="@dimen/widget_margin">
+  android:padding="@dimen/widget_margin">
 
   <LinearLayout
     android:layout_width="match_parent"
@@ -295,16 +297,16 @@ use flexible layouts attributes like so:

When a user adds the widget to their home screen, on an example Android 4.0 device where each -grid cell is 80dp × 100dp in size and 16dp of margins are automatically applied on all sizes, +grid cell is 80dp × 100dp in size and 8dp of margins are automatically applied on all sizes, the widget will be stretched, like so:

Music widget sitting on an example 80dp x 100dp grid with 16dp of automatic margins
+  alt=

Figure 7. Music widget sitting on an example 80dp x 100dp -grid with 16dp of automatic margins added by the system.

+grid with 8dp of automatic margins added by the system.

Using the App Widget Templates Pack

diff --git a/docs/html/guide/topics/appwidgets/index.jd b/docs/html/guide/topics/appwidgets/index.jd index 61337b782a750..2cb23c1cdbbab 100644 --- a/docs/html/guide/topics/appwidgets/index.jd +++ b/docs/html/guide/topics/appwidgets/index.jd @@ -346,7 +346,7 @@ following layout classes:

<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_margin="@dimen/widget_margin"> + android:padding="@dimen/widget_margin"> <LinearLayout android:layout_width="match_parent" @@ -363,7 +363,7 @@ following layout classes:

  • Create two dimensions resources, one in res/values/ to provide the pre-Android 4.0 custom margins, and one in res/values-v14/ to provide no extra padding for Android 4.0 widgets:

    res/values/dimens.xml:
    -

    <dimen name="widget_margin">15dp</dimen>

    +
    <dimen name="widget_margin">8dp</dimen>

    res/values-v14/dimens.xml:

    <dimen name="widget_margin">0dp</dimen>