Home | History | Annotate | Download | only in ui_guidelines
      1 page.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 screen</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
     39 application's most important or timely information at a glance, on a user's Home
     40 screen. The standard Android system image includes several examples of widgets,
     41 including 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 &amp; holding an empty area of the Home screen, selecting Widgets from the menu,
     45 and then selecting the widget they want.</p>
     46 
     47 <p><img src="{@docRoot}images/widget_design/widget_examples.png" alt="Example
     48 Widgets"></p>
     49 
     50 <p>This document describes how to design a widget so it fits graphically with
     51 other widgets and with the other elements of the Android Home screen. It also
     52 describes some standards for widget artwork and some widget graphics tips and
     53 tricks from the Android team.<p>
     54 
     55 <p>For information about developing widgets, see the <a
     56 href="{@docRoot}guide/topics/appwidgets/index.html">AppWidgets</a> section of
     57 the <em>Developer's Guide</em> and the <a
     58 href="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,
     64 and the widget's graphical controls and other elements. Well-designed widgets
     65 leave some padding between the edges of the bounding box and the frame, and
     66 between the inner edges of the frame and the widget's controls. Widgets designed
     67 to fit visually with other widgets on the Home screen take cues from the other
     68 elements on the Home screen for alignment; they also use standard shading
     69 effects. 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"
     73 alt="Standard Widget Sizes in Portrait Orientation"></p>
     74 
     75 <p>&nbsp;</p>
     76 
     77 <p><strong>Standard Widget Sizes in Landscape Orientation</strong><br/>
     78 <img src="{@docRoot}images/widget_design/widget_sizes_landscape.png"
     79 alt="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
     88 data in the smallest widget size. Users will weigh the usefulness or your widget
     89 against 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
     92 widget sizes, or better yet, within a pair of portrait and landscape orientation
     93 sizes, so your widget looks good when the user switches screen
     94 orientations.</p> 
     95 
     96 <p><a href="#sizes">Standard widget sizes</a> illustrates the bounding
     97 dimensions of the six widget sizes (three in portrait and three in landscape
     98 orientation).</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
    104 for the six widget sizes, with links so you can download copies for your own
    105 use. You don't have to use these frames for your widget, but if you do, your
    106 widgets 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
    111 widget 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
    117 href="{@docRoot}images/widget_design/Music_widget_button_states.psd">download a
    118 Photoshop file that contains the three states of the Play button</a>, taken from
    119 the Music widget, to analyze the Photoshop settings used for the three standard
    120 button effects.</p>
    121 
    122 <p><a href="{@docRoot}images/widget_design/Music_widget_button_states.psd"> <img
    123 src="{@docRoot}images/widget_design/buttons.png" alt="Click to download
    124 Photoshop template"></a></p>
    125  
    126 <li><strong>Finish drawing your artwork and then scale and align it to
    127 fit.</strong></li>
    128 
    129 <p><a href="#tricks">Widget alignment tips and tricks</a> describes some
    130 techniques for aligning your widget's graphics inside the standard frames, along
    131 with a few other widget graphics tricks.</p>
    132 
    133 <li><strong>Save your widget with the correct graphics file
    134 settings.</strong></li>
    135 
    136 <p><a href="#file">Windows graphics file format</a> describes the correct
    137 settings 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
    146 for the six standard widget sizes. The contents of typical widgets don't draw to
    147 the edge of these dimensions, but fit inside a frame withing the bounding box,
    148 as 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
    151 diagram shows a cell in portrait orientation). The three supported widget sizes
    152 in 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
    162 dimensions in portrait orientation"></p>
    163 
    164 <p>In landscape orientation, each cell is 106 pixels wide by 74 pixels tall. The
    165 three 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
    175 dimensions 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
    181 click the images of the frames in this section to download a Photoshop file for
    182 that 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
    185 src="{@docRoot}images/widget_design/4x1_Widget_Frame_Portrait.png" alt="Click to
    186 download"></a><br>4x1_Widget_Frame_Portrait.psd</p>
    187 
    188 <p><a href="{@docRoot}images/widget_design/3x3_Widget_Frame_Portrait.psd"> <img
    189 src="{@docRoot}images/widget_design/3x3_Widget_Frame_Portrait.png" alt="Click to
    190 download"></a><br>3x3_Widget_Frame_Portrait.psd</p>
    191 
    192 <p><a href="{@docRoot}images/widget_design/2x2_Widget_Frame_Portrait.psd"> <img
    193 src="{@docRoot}images/widget_design/2x2_Widget_Frame_Portrait.png" alt="Click to
    194 download"></a><br>2x2_Widget_Frame_Portrait.psd</p>
    195 
    196 <p><a href="{@docRoot}images/widget_design/4x1_Widget_Frame_Landscape.psd"> <img
    197 src="{@docRoot}images/widget_design/4x1_Widget_Frame_Landscape.png" alt="Click
    198 to download"></a><br>4x1_Widget_Frame_Landscape.psd</p>
    199 
    200 <p><a href="{@docRoot}images/widget_design/3x3_Widget_Frame_Landscape.psd"> <img
    201 src="{@docRoot}images/widget_design/3x3_Widget_Frame_Landscape.png" alt="Click
    202 to download"></a><br>3x3_Widget_Frame_Landscape.psd</p>
    203 
    204 <p><a href="{@docRoot}images/widget_design/2x2_Widget_Frame_Landscape.psd"> <img
    205 src="{@docRoot}images/widget_design/2x2_Widget_Frame_Landscape.png" alt="Click
    206 to 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
    212 standard Android widgets, using the following settings in the Photoshop Layer
    213 Style dialog box.</p>
    214 
    215 <p><img src="{@docRoot}images/widget_design/Layer_Style.png" alt="Layer Style
    216 settings 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
    222 within standard widget bounding boxes and frames, so the widget aligns visually
    223 with other widgets and the other elements of the Home screen, as well as other
    224 techniques for creating widgets.
    225 
    226 <ul>
    227 
    228 <li>Use a screen shot from the Android SDK emulator to align both the shapes and
    229 shadows of your widget controls with the Search widget and with other elements
    230 on the Home screen.</li>
    231 
    232 <p>Cut the widget artwork asset" based on the full size of a cell, including any
    233 padding you want. (That is, for a 4 x 1 widget, cut the asset at 320 by 100
    234 pixels.)</p>
    235 
    236 <p><img src="{@docRoot}images/widget_design/alignment.png" alt="Aligning widget
    237 graphics" ></p>
    238 
    239 <li>To reduce banding when exporting a widget, apply the following Photoshop Add
    240 Noise setting to your graphic.</li>
    241 
    242 <p><img src="{@docRoot}images/widget_design/Add_Noise.png" alt="Add Noise
    243 settings for widget graphics" ></p>
    244 
    245 <li>Apply 9-patch techniques to shrink the graphic and set the padding of the
    246 content area. (<a href="{@docRoot}guide/developing/tools/draw9patch.html">See
    247 the detailed guide here.</a>)</li>
    248 
    249 <p><strong>Note:</strong> The current Android widget templates were designed
    250 using a custom gradient angle, which means the 9-patch techniques can't be used
    251 to optimize the size of the asset. However, 9-patch techniques were used to set
    252 the content area padding.</p>
    253 
    254 <li>In some cases, devices have low pixel depths that can cause visual banding
    255 and dithering issues. To solve this, application developers should pass assets
    256 through a "proxy" drawable defined as <code>XML:<nine-patch
    257 android:src="@drawable/background" android:dither="true" /></code>. This
    258 technique references the original artwork, in this case
    259 <code>"background.9.png"</code>, and instructs the device to dither it as
    260 needed.</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
    267 format 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