1page.title=Widget Design Guidelines 2@jd:body 3 4<div id="qv-wrapper"> 5<div id="qv"> 6 7<h2>Widget design quickview</h2> 8 9<ul> 10<li>Widgets have six standard sizes on the Home screen</li> 11<li>Widgets have standards for size, frames, shadows, and file format, which you can copy</li> 12<li>A few tricks make it easier to design widgets that fit graphically on the Home screeen</li> 13</ul> 14 15<h2>In this document</h2> 16 17<ol> 18<li><a href="#anatomy">Standard widget anatomy</a></li> 19<li><a href="#design">Designing a widget</a></li> 20<li><a href="#sizes">Standard widget sizes</a></li> 21<li><a href="#frames">Standard widget frames</a></li> 22<li><a href="#shadows">Standard widget shadows</a></li> 23<li><a href="#tricks">Widget graphics tips and tricks</a></li> 24<li><a href="#file">Widget graphics file format</a></li> 25</ol> 26 27<h2>See also</h2> 28 29<ol> 30<li><a href="{@docRoot}guide/topics/appwidgets/index.html">AppWidgets</a> topic in the <em>Dev Guide</em></li> 31<li><a href="http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html">AppWidgets blog post</a></li> 32</ol> 33 34</div> 35</div> 36 37 38<p>Widgets are a feature introduced in Android 1.5. A widget displays an 39application's most important or timely information at a glance, on a user's Home 40screen. The standard Android system image includes several examples of widgets, 41including widgets for Analog Clock, Music, and other applications.</p> 42 43<p>Users pick the widgets they want to display on their Home screens by touching 44& holding an empty area of the Home screen, selecting Widgets from the menu, 45and then selecting the widget they want.</p> 46 47<p><img src="{@docRoot}images/widget_design/widget_examples.png" alt="Example 48Widgets"></p> 49 50<p>This document describes how to design a widget so it fits graphically with 51other widgets and with the other elements of the Android Home screen. It also 52describes some standards for widget artwork and some widget graphics tips and 53tricks from the Android team.<p> 54 55<p>For information about developing widgets, see the <a 56href="{@docRoot}guide/topics/appwidgets/index.html">AppWidgets</a> section of 57the <em>Developer's Guide</em> and the <a 58href="http://android-developers.blogspot.com/2009/04/introducing-home-screen-widgets-and.html">AppWidgets</a> blog post.</p> 59 60 61<h2 id="anatomy">Standard widget anatomy</h2> 62 63<p>Typical Android widgets have three main components: A bounding box, a frame, 64and the widget's graphical controls and other elements. Well-designed widgets 65leave some padding between the edges of the bounding box and the frame, and 66between the inner edges of the frame and the widget's controls. Widgets designed 67to fit visually with other widgets on the Home screen take cues from the other 68elements on the Home screen for alignment; they also use standard shading 69effects. All of these details are described in this document. 70 71<p><strong>Standard Widget Sizes in Portrait Orientation</strong><br/> 72<img src="{@docRoot}images/widget_design/widget_sizes_portrait.png" 73alt="Standard Widget Sizes in Portrait Orientation"></p> 74 75<p> </p> 76 77<p><strong>Standard Widget Sizes in Landscape Orientation</strong><br/> 78<img src="{@docRoot}images/widget_design/widget_sizes_landscape.png" 79alt="Standard Widget Sizes in Landscape Orientation"></p> 80 81 82<h2 id="design">Designing a widget</h2> 83 84<ol> 85<li><strong>Select a bounding box size for your widget.</strong></li> 86 87<p>The most effective widgets display your application's most useful or timely 88data in the smallest widget size. Users will weigh the usefulness or your widget 89against the portion of the Home screen it covers, so the smaller the better.</p> 90 91<p>All widgets must fit within the bounding box of one of the six supported 92widget sizes, or better yet, within a pair of portrait and landscape orientation 93sizes, so your widget looks good when the user switches screen 94orientations.</p> 95 96<p><a href="#sizes">Standard widget sizes</a> illustrates the bounding 97dimensions of the six widget sizes (three in portrait and three in landscape 98orientation).</p> 99 100 101<li><strong>Select a matching frame.</strong></li> 102 103<p><a href="#frames">Standard widget frames</a> illustrates the standard frames 104for the six widget sizes, with links so you can download copies for your own 105use. You don't have to use these frames for your widget, but if you do, your 106widgets are more likely to fit visually with other widgets.</p> 107 108<li><strong>Apply standard shadow effect to your graphics.</strong></li> 109 110<p>Again, you don't have to use this effect, but <a href="#shadows">Standard 111widget shadows</a> shows the Photoshop settings used for standard widgets.</p> 112 113<li><strong>If your widget includes buttons, draw them in three states 114(default, pressed, and selected).</strong></li> 115 116<p>You can <a 117href="{@docRoot}images/widget_design/Music_widget_button_states.psd">download a 118Photoshop file that contains the three states of the Play button</a>, taken from 119the Music widget, to analyze the Photoshop settings used for the three standard 120button effects.</p> 121 122<p><a href="{@docRoot}images/widget_design/Music_widget_button_states.psd"> <img 123src="{@docRoot}images/widget_design/buttons.png" alt="Click to download 124Photoshop template"></a></p> 125 126<li><strong>Finish drawing your artwork and then scale and align it to 127fit.</strong></li> 128 129<p><a href="#tricks">Widget alignment tips and tricks</a> describes some 130techniques for aligning your widget's graphics inside the standard frames, along 131with a few other widget graphics tricks.</p> 132 133<li><strong>Save your widget with the correct graphics file 134settings.</strong></li> 135 136<p><a href="#file">Windows graphics file format</a> describes the correct 137settings for your widget graphics files.</p> 138 139</ol> 140 141 142<h2 id="sizes">Standard widget sizes</h2> 143 144<p>There are six standard widget sizes, based on a Home screen grid of 4 x 4 145(portrait) or 4 x 4 (landscape) cells. These dimensions are the bounding boxes 146for the six standard widget sizes. The contents of typical widgets don't draw to 147the edge of these dimensions, but fit inside a frame withing the bounding box, 148as described in <a href="#design">Designing a widget</a>.</p> 149 150<p>In portrait orientation, each cell is 80 pixels wide by 100 pixels tall (the 151diagram shows a cell in portrait orientation). The three supported widget sizes 152in portrait orientation are:<p> 153 154<table> 155<tr><th>Cells</th><th>Pixels</th></tr> 156<tr><td>4 x 1</td><td>320 x 100</td></tr> 157<tr><td>3 x 3</td><td>240 x 300</td></tr> 158<tr><td>2 x 2</td><td>160 x 200</td></tr> 159</table> 160 161<p><img src="{@docRoot}images/widget_design/portrait_sizes.png" alt="Widget 162dimensions in portrait orientation"></p> 163 164<p>In landscape orientation, each cell is 106 pixels wide by 74 pixels tall. The 165three supported widget sizes in landscape orientation are:</p> 166 167<table> 168<tr><th>Cells</th><th>Pixels</th></tr> 169<tr><td>4 x 1</td><td>424 x 74</td></tr> 170<tr><td>3 x 3</td><td>318 x 222</td></tr> 171<tr><td>2 x 2</td><td>212 x 148</td></tr> 172</table> 173 174<p><img src="{@docRoot}images/widget_design/landscape_sizes.png" alt="Widget 175dimensions in landscape orientation"></p> 176 177 178<h2 id="frames">Standard widget frames</h2> 179 180<p>For each of the six standard widget sizes there is a standard frame. You can 181click the images of the frames in this section to download a Photoshop file for 182that frame, which you can use for your own widgets.<p> 183 184<p><a href="{@docRoot}images/widget_design/4x1_Widget_Frame_Portrait.psd"> <img 185src="{@docRoot}images/widget_design/4x1_Widget_Frame_Portrait.png" alt="Click to 186download"></a><br>4x1_Widget_Frame_Portrait.psd</p> 187 188<p><a href="{@docRoot}images/widget_design/3x3_Widget_Frame_Portrait.psd"> <img 189src="{@docRoot}images/widget_design/3x3_Widget_Frame_Portrait.png" alt="Click to 190download"></a><br>3x3_Widget_Frame_Portrait.psd</p> 191 192<p><a href="{@docRoot}images/widget_design/2x2_Widget_Frame_Portrait.psd"> <img 193src="{@docRoot}images/widget_design/2x2_Widget_Frame_Portrait.png" alt="Click to 194download"></a><br>2x2_Widget_Frame_Portrait.psd</p> 195 196<p><a href="{@docRoot}images/widget_design/4x1_Widget_Frame_Landscape.psd"> <img 197src="{@docRoot}images/widget_design/4x1_Widget_Frame_Landscape.png" alt="Click 198to download"></a><br>4x1_Widget_Frame_Landscape.psd</p> 199 200<p><a href="{@docRoot}images/widget_design/3x3_Widget_Frame_Landscape.psd"> <img 201src="{@docRoot}images/widget_design/3x3_Widget_Frame_Landscape.png" alt="Click 202to download"></a><br>3x3_Widget_Frame_Landscape.psd</p> 203 204<p><a href="{@docRoot}images/widget_design/2x2_Widget_Frame_Landscape.psd"> <img 205src="{@docRoot}images/widget_design/2x2_Widget_Frame_Landscape.png" alt="Click 206to download"></a><br>2x2_Widget_Frame_Landscape.psd</p> 207 208 209<h2 id="shadows">Standard widget shadows</h2> 210 211<p>You can apply a shadow effect to your widget's artwork, so it matches other 212standard Android widgets, using the following settings in the Photoshop Layer 213Style dialog box.</p> 214 215<p><img src="{@docRoot}images/widget_design/Layer_Style.png" alt="Layer Style 216settings for standard shadows"></p> 217 218 219<h2 id="tricks">Widget graphics tips and tricks</h2> 220 221<p>The Android team has developed a few tricks for aligning widget artwork 222within standard widget bounding boxes and frames, so the widget aligns visually 223with other widgets and the other elements of the Home screen, as well as other 224techniques for creating widgets. 225 226<ul> 227 228<li>Use a screen shot from the Android SDK emulator to align both the shapes and 229shadows of your widget controls with the Search widget and with other elements 230on the Home screen.</li> 231 232<p>Cut the widget artwork asset" based on the full size of a cell, including any 233padding you want. (That is, for a 4 x 1 widget, cut the asset at 320 by 100 234pixels.)</p> 235 236<p><img src="{@docRoot}images/widget_design/alignment.png" alt="Aligning widget 237graphics" ></p> 238 239<li>To reduce banding when exporting a widget, apply the following Photoshop Add 240Noise setting to your graphic.</li> 241 242<p><img src="{@docRoot}images/widget_design/Add_Noise.png" alt="Add Noise 243settings for widget graphics" ></p> 244 245<li>Apply 9-patch techniques to shrink the graphic and set the padding of the 246content area. (<a href="{@docRoot}guide/developing/tools/draw9patch.html">See 247the detailed guide here.</a>)</li> 248 249<p><strong>Note:</strong> The current Android widget templates were designed 250using a custom gradient angle, which means the 9-patch techniques can't be used 251to optimize the size of the asset. However, 9-patch techniques were used to set 252the content area padding.</p> 253 254<li>In some cases, devices have low pixel depths that can cause visual banding 255and dithering issues. To solve this, application developers should pass assets 256through a "proxy" drawable defined as <code>XML:<nine-patch 257android:src="@drawable/background" android:dither="true" /></code>. This 258technique references the original artwork, in this case 259<code>"background.9.png"</code>, and instructs the device to dither it as 260needed.</li> 261 262</ul> 263 264<h2 id="file">Widget graphics file format</h2> 265 266<p>Save your widget artwork using the appropriate bounding box size in PNG-24 267format on a transparent background and in 8-bit color.</p> 268 269<p><img src="{@docRoot}images/widget_design/file_format.png" alt="Widget graphics file format" ></p> 270 271 272 273 274 275