You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/html/guide/topics/appwidgets/index.jd
+43Lines changed: 43 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -327,6 +327,49 @@ following layout classes:</p>
327
327
<p>Descendants of these classes are not supported.</p>
328
328
329
329
330
+
<h3 id="AddingMargins">Adding margins to App Widgets</h3>
331
+
332
+
<p>Widgets should not generally extend to screen edges and should not visually be flush with other widgets, so you should add margins on all sides around your widget frame.</p>
333
+
334
+
<p>As of Android 4.0, app widgets are automatically given padding between the widget frame and the app widget's bounding box to provide better alignment with other widgets and icons on the user's home screen. To take advantage of this strongly recommended behavior, set your application's <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">targetSdkVersion</a> to 14 or greater.</p>
335
+
336
+
<p>It's easy to write a single layout that has custom margins applied for earlier versions of the platform, and has no extra margins for Android 4.0 and greater:</p>
337
+
338
+
<ol>
339
+
<li>Set your application's <code>targetSdkVersion</code> to 14 or greater.</li>
340
+
<li>Create a layout such as the one below, that references a <a href="{@docRoot}guide/topics/resources/more-resources.html#Dimension">dimension resource</a> for its margins:
<li>Create two dimensions resources, one in <code>res/values/</code> to provide the pre-Android 4.0 custom margins, and one in <code>res/values-v14/</code> to provide no extra padding for Android 4.0 widgets:
<p>Another option is to simply build extra margins into your <a href="{@docRoot}guide/topics/graphics/2d-graphics.html#nine-patch">nine-patch</a> background assets by default, and provide different nine-patches with no margins for API level 14 or later.</p>
371
+
372
+
330
373
<h2 id="AppWidgetProvider">Using the AppWidgetProvider Class</h2>
0 commit comments