| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 1 | page.title=Action Bar |
| 2 | @jd:body |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 3 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 4 | <img src="{@docRoot}design/media/action_bar_pattern_overview.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 5 | |
| 6 | <p>The <em>action bar</em> is arguably the most important structural element of an Android app. It's a |
| 7 | dedicated piece of real estate at the top of each screen that is generally persistent throughout the |
| 8 | app.</p> |
| 9 | <p><strong>The main purpose of the action bar is to</strong>:</p> |
| 10 | <ul> |
| 11 | <li>Make important actions (such as <em>New</em> or <em>Search</em>, etc) prominent and accessible in a predictable |
| 12 | way.</li> |
| 13 | <li>Support consistent navigation and view switching within apps.</li> |
| 14 | <li>Reduce clutter by providing an action overflow for rarely used actions.</li> |
| 15 | <li>Provide a dedicated space for giving your app an identity.</li> |
| 16 | </ul> |
| 17 | <p>If you're new to writing Android apps, note that the action bar is one of the most important design |
| 18 | elements you can implement. Following the guidelines described here will go a long way toward making |
| 19 | your app's interface consistent with the core Android apps.</p> |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 20 | <h2 id="organization">General Organization</h2> |
| 21 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 22 | <p>The action bar is split into four different functional areas that apply to most apps.</p> |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 23 | <img src="{@docRoot}design/media/action_bar_basics.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 24 | |
| 25 | <div class="layout-content-row"> |
| 26 | <div class="layout-content-col span-7 with-callouts"> |
| 27 | |
| 28 | <ol> |
| 29 | <li class="value-1"><h4>App icon</h4> |
| 30 | <p> |
| 31 | |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 32 | The app icon establishes your app's identity. It can be replaced with a different logo or branding |
| 33 | if you wish. |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 34 | Important: If the app is currently not displaying the top-level screen, be sure to display the Up |
| 35 | caret to the left of the app icon, so the user can navigate up the hierarchy. For more discussion of |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 36 | Up navigation, see the <a href="{@docRoot}design/patterns/navigation.html">Navigation</a> pattern. |
| Scott Main | 59ea115 | 2012-06-15 14:52:01 -0700 | [diff] [blame^] | 37 | </p> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 38 | |
| Scott Main | 59ea115 | 2012-06-15 14:52:01 -0700 | [diff] [blame^] | 39 | <img src="{@docRoot}design/media/action_bar_pattern_up_app_icon.png"> |
| 40 | <div class="figure-caption"> |
| 41 | App icon with and without "up" affordance. |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 42 | </div> |
| 43 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 44 | </li> |
| 45 | </ol> |
| 46 | |
| 47 | </div> |
| 48 | <div class="layout-content-col span-6 with-callouts"> |
| 49 | |
| 50 | <ol> |
| 51 | <li class="value-2"><h4>View control</h4> |
| 52 | <p> |
| 53 | |
| 54 | If your app displays data in different views, this segment of the action bar allows users to switch |
| 55 | views. Examples of view-switching controls are drop-down menus or tab controls. |
| 56 | |
| 57 | </p> |
| 58 | <p> |
| 59 | |
| 60 | If your app doesn't support different views, you can also use this space to display non-interactive |
| 61 | content, such as an app title or longer branding information. |
| 62 | |
| 63 | </p> |
| 64 | </li> |
| 65 | <li class="value-3"><h4>Action buttons</h4> |
| 66 | <p> |
| 67 | |
| 68 | Show the most important actions of your app in the actions section. Actions that don't fit in the |
| 69 | action bar are moved automatically to the action overflow. |
| 70 | |
| 71 | </p> |
| 72 | </li> |
| 73 | <li class="value-4"><h4>Action overflow</h4> |
| 74 | <p> |
| 75 | |
| 76 | Move less often used actions to the action overflow. |
| 77 | |
| 78 | </p> |
| 79 | </li> |
| 80 | </ol> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 81 | </div> |
| 82 | </div> |
| 83 | |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 84 | <h2 id="adapting-rotation">Adapting to Rotation and Different Screen Sizes</h2> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 85 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 86 | <p>One of the most important UI issues to consider when creating an app is how to adjust to screen |
| 87 | rotation on different screen sizes.</p> |
| 88 | <p>You can adapt to such changes by using <em>split action bars</em>, which allow you to distribute action bar |
| 89 | content across multiple bars located below the main action bar or at the bottom of the screen.</p> |
| 90 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 91 | <img src="{@docRoot}design/media/action_bar_pattern_rotation.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 92 | <div class="figure-caption"> |
| 93 | Split action bar showing action buttons at the bottom of the screen in vertical orientation. |
| 94 | </div> |
| 95 | |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 96 | <h2 id="considerations-split-action-bars">Layout Considerations for Split Action Bars</h2> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 97 | |
| 98 | <div class="layout-content-row"> |
| 99 | <div class="layout-content-col span-8 with-callouts"> |
| 100 | |
| 101 | <p>When splitting up content across multiple action bars, you generally have three possible locations |
| 102 | for action bar content:</p> |
| 103 | <ol> |
| 104 | <li><strong>Main action bar</strong></li> |
| 105 | <li><strong>Top bar</strong></li> |
| 106 | <li><strong>Bottom bar</strong></li> |
| 107 | </ol> |
| 108 | <p>If the user can navigate up the hierarchy from a given screen, the main action bar contains the up |
| 109 | caret, at a minimum.</p> |
| 110 | <p>To allow the user to quickly switch between the views your app provides, use tabs or a spinner in |
| 111 | the top bar.</p> |
| 112 | <p>To display actions and, if necessary, the action overflow, use the bottom bar.</p> |
| 113 | |
| 114 | </div> |
| Scott Main | 59ea115 | 2012-06-15 14:52:01 -0700 | [diff] [blame^] | 115 | <div class="layout-content-col span-5"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 116 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 117 | <img src="{@docRoot}design/media/action_bar_pattern_considerations.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 118 | |
| 119 | </div> |
| 120 | </div> |
| 121 | |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 122 | <h2 id="contextual">Contextual Action Bars</h2> |
| 123 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 124 | <p>A <em>contextual action bar (CAB)</em> is a temporary action bar that overlays the app's action bar for the |
| 125 | duration of a particular sub-task. CABs are most typically used for tasks that involve acting on |
| 126 | selected data or text.</p> |
| 127 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 128 | <img src="{@docRoot}design/media/action_bar_cab.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 129 | <div class="figure-caption"> |
| 130 | Contextual action bar shown in Browser and Gmail |
| 131 | </div> |
| 132 | |
| 133 | <p>The selection CAB appears after a long press on a selectable data item triggers selection mode.</p> |
| 134 | <p><strong>From here the user can</strong>:</p> |
| 135 | <ul> |
| 136 | <li>Select additional elements by touching them.</li> |
| 137 | <li>Trigger an action from the CAB that applies to all selected data items. The CAB then |
| 138 | automatically dismisses itself.</li> |
| 139 | <li>Dismiss the CAB via the navigation bar's Back button or the CAB's checkmark button. This removes |
| 140 | the CAB along with all selection highlights.</li> |
| 141 | </ul> |
| 142 | <p>Use CABs whenever you allow the user to select data via long press. You can control the action |
| 143 | content of a CAB in order to insert the actions you would like the user to be able to perform.</p> |
| 144 | <p>For more information, refer to the "Selection" pattern.</p> |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 145 | <h2 id="elements">Action Bar Elements</h2> |
| 146 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 147 | <h4>Tabs</h4> |
| 148 | <p><em>Tabs</em> display app views concurrently and make it easy to explore and switch between them. Use tabs |
| 149 | if you expect your users to switch views frequently.</p> |
| 150 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 151 | <img src="{@docRoot}design/media/tabs_youtube.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 152 | |
| 153 | <p>There are two types of tabs: fixed and scrollable.</p> |
| 154 | |
| 155 | <div class="layout-content-row"> |
| 156 | <div class="layout-content-col span-6"> |
| 157 | |
| 158 | <h4>Scrollable tabs</h4> |
| 159 | <p><em>Scrollable tabs</em> always take up the entire width of the bar, with the currently active view item in |
| 160 | the center, and therefore need to live in a dedicated bar. Scrollable tabs can themselves be |
| 161 | scrolled horizontally to bring more tabs into view.</p> |
| 162 | <p>Use scrollable tabs if you have a large number of views or if you're unsure how many views will be |
| 163 | displayed because your app inserts views dynamically (for example, open chats in a messaging app |
| 164 | that the user can navigate between). Scrollable tabs should always allow the user to navigate |
| 165 | between the views by swiping left or right on the content area as well as swiping the tabs |
| 166 | themselves.</p> |
| 167 | |
| 168 | </div> |
| 169 | <div class="layout-content-col span-7"> |
| 170 | |
| 171 | <video width="400" class="with-shadow play-on-hover" autoplay> |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 172 | <source src="{@docRoot}design/media/tabs_scrolly.mp4" type="video/mp4"> |
| 173 | <source src="{@docRoot}design/media/tabs_scrolly.webm" type="video/webm"> |
| 174 | <source src="{@docRoot}design/media/tabs_scrolly.ogv" type="video/ogg"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 175 | </video> |
| 176 | <div class="figure-caption"> |
| Roman Nurik | b20f120 | 2012-03-29 13:28:13 -0700 | [diff] [blame] | 177 | Scrolling tabs in the Play Store app. |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 178 | <div class="video-instructions"> </div> |
| 179 | </div> |
| 180 | |
| 181 | </div> |
| 182 | </div> |
| 183 | |
| 184 | <div class="layout-content-row"> |
| 185 | <div class="layout-content-col span-6"> |
| 186 | |
| 187 | <h4>Fixed tabs</h4> |
| 188 | <p><em>Fixed tabs</em> are always visible on the screen, and can't be moved out of the way like scrollable |
| 189 | tabs. Fixed tabs in the main action bar can move to the top bar when the screen orientation changes.</p> |
| 190 | |
| 191 | </div> |
| 192 | <div class="layout-content-col span-7"> |
| 193 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 194 | <img src="{@docRoot}design/media/action_bar_pattern_default_tabs.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 195 | <div class="figure-caption"> |
| 196 | Default fixed tabs shown in Holo Dark & Light. |
| 197 | </div> |
| 198 | |
| 199 | </div> |
| 200 | </div> |
| 201 | |
| 202 | <div class="layout-content-row"> |
| 203 | <div class="layout-content-col span-6"> |
| 204 | |
| 205 | <h4>Spinners</h4> |
| 206 | <p>A <em>spinner</em> is a drop-down menu that allows users to switch between views of your app. </p> |
| 207 | <p><strong>Use spinners rather than tabs in the main action bar if</strong>:</p> |
| 208 | <ul> |
| 209 | <li>You don't want to give up the vertical screen real estate for a dedicated tab bar.</li> |
| 210 | <li>You expect your app's users to switch views infrequently.</li> |
| 211 | </ul> |
| 212 | |
| 213 | </div> |
| 214 | <div class="layout-content-col span-7"> |
| 215 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 216 | <img src="{@docRoot}design/media/action_bar_pattern_spinner.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 217 | <div class="figure-caption"> |
| 218 | Action bar spinner from Calendar application. |
| 219 | </div> |
| 220 | |
| 221 | </div> |
| 222 | </div> |
| 223 | |
| 224 | <h4>Action buttons</h4> |
| 225 | <p><em>Action buttons</em> on the action bar surface your app's most important activities. Think about which |
| 226 | buttons will get used most often, and order them accordingly. Depending on available screen real |
| 227 | estate, the system shows your most important actions as action buttons and moves the rest to the |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 228 | action overflow. The action bar and the action overflow should only present actions to the user that |
| 229 | are available. If an action is unavailable in the current context, hide it. Do not show it as |
| 230 | disabled.</p> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 231 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 232 | <img src="{@docRoot}design/media/action_bar_pattern_action_icons.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 233 | <div class="figure-caption"> |
| 234 | A sampling of action buttons used throughout the Gmail application. |
| 235 | </div> |
| 236 | |
| 237 | <p>For guidance on prioritizing actions, use the FIT scheme.</p> |
| 238 | |
| 239 | <div class="layout-content-row"> |
| 240 | <div class="layout-content-col span-4"> |
| 241 | |
| 242 | <p><strong>F — Frequent</strong></p> |
| 243 | <ul> |
| 244 | <li>Will people use this action at least 7 out of 10 times they visit the screen?</li> |
| 245 | <li>Will they typically use it several times in a row?</li> |
| 246 | <li>Would taking an extra step every time truly be burdensome?</li> |
| 247 | </ul> |
| 248 | |
| 249 | </div> |
| 250 | <div class="layout-content-col span-4"> |
| 251 | |
| 252 | <p><strong>I — Important</strong></p> |
| 253 | <ul> |
| 254 | <li>Do you want everyone to discover this action because it's especially cool or a selling point?</li> |
| 255 | <li>Is it something that needs to be effortless in the rare cases it's needed?</li> |
| 256 | </ul> |
| 257 | |
| 258 | </div> |
| 259 | <div class="layout-content-col span-4"> |
| 260 | |
| 261 | <p><strong>T — Typical</strong></p> |
| 262 | <ul> |
| 263 | <li>Is it typically presented as a first-class action in similar apps?</li> |
| 264 | <li>Given the context, would people be surprised if it were buried in the action overflow?</li> |
| 265 | </ul> |
| 266 | |
| 267 | </div> |
| 268 | </div> |
| 269 | |
| 270 | <p>If either F, I, or T apply, then it's appropriate for the action bar. Otherwise, it belongs in the |
| 271 | action overflow.</p> |
| 272 | |
| Roman Nurik | bb9bffb | 2012-01-26 14:56:28 -0800 | [diff] [blame] | 273 | <p> |
| 274 | |
| 275 | Pre-defined glyphs should be used for certain common actions such as "refresh" and "share." The |
| 276 | download link below provides a package with icons that are scaled for various screen densities and |
| 277 | are suitable for use with the Holo Light and Holo Dark themes. The package also includes unstyled |
| 278 | icons that you can modify to match your theme, in addition to Adobe® Illustrator® source |
| 279 | files for further customization. |
| 280 | |
| 281 | </p> |
| 282 | <p> |
| 283 | |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 284 | <a href="https://dl-ssl.google.com/android/design/Android_Design_Icons_20120229.zip">Download the Action Bar Icon Pack</a> |
| Roman Nurik | bb9bffb | 2012-01-26 14:56:28 -0800 | [diff] [blame] | 285 | |
| 286 | </p> |
| 287 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 288 | <div class="layout-content-row"> |
| 289 | <div class="layout-content-col span-6"> |
| 290 | |
| 291 | <h4>Action overflow</h4> |
| 292 | <p>The action overflow in the action bar provides access to your app's less frequently used actions. |
| 293 | The overflow icon only appears on phones that have no menu hardware keys. Phones with menu keys |
| 294 | display the action overflow when the user presses the key.</p> |
| 295 | |
| 296 | </div> |
| 297 | <div class="layout-content-col span-7"> |
| 298 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 299 | <img src="{@docRoot}design/media/action_bar_pattern_overflow.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 300 | <div class="figure-caption"> |
| 301 | Action overflow is pinned to the right side. |
| 302 | </div> |
| 303 | |
| 304 | </div> |
| 305 | </div> |
| 306 | |
| 307 | <p>How many actions will fit in the main action bar? Action bar capacity is controlled by the following |
| 308 | rules:</p> |
| 309 | <ul> |
| 310 | <li>Action buttons in the main action bar may not occupy more than 50% of the bar's width. Action |
| 311 | buttons on bottom action bars can use the entire width.</li> |
| 312 | <li>The screen width in density-independent pixels |
| 313 | (<acronym title="Density-independent pixels. One dp is one pixel on a 160 dpi screen.">dp</acronym>) |
| 314 | determine the number of items that will fit in the main action bar:<ul> |
| 315 | <li>smaller than 360 dp = 2 icons</li> |
| 316 | <li>360-499 dp = 3 icons</li> |
| 317 | <li>500-599 dp = 4 icons</li> |
| 318 | <li>600 dp and larger = 5 icons</li> |
| 319 | </ul> |
| 320 | </li> |
| 321 | </ul> |
| 322 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 323 | <img src="{@docRoot}design/media/action_bar_pattern_table.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 324 | <div class="figure-caption"> |
| 325 | In the above table "o" denotes an action bar item and "=" an overflow icon. |
| 326 | </div> |
| 327 | |
| 328 | <h4>Sharing data</h4> |
| 329 | <p>Whenever your app permits sharing of data, such as images or movie clips, use a <em>share action |
| 330 | provider</em> in your action bar. The share action provider is designed to speed up sharing by |
| 331 | displaying the most recently used sharing service next to a spinner button that contains other |
| 332 | sharing options.</p> |
| 333 | |
| Roman Nurik | b99ae73 | 2012-03-06 12:26:15 -0800 | [diff] [blame] | 334 | <img src="{@docRoot}design/media/action_bar_pattern_share_pack.png"> |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 335 | <div class="figure-caption"> |
| 336 | The Gallery app's share action provider with extended spinner for additional sharing options. |
| 337 | </div> |
| 338 | |
| Roman Nurik | a53b3bf | 2012-02-29 11:59:32 -0800 | [diff] [blame] | 339 | <h2 id="checklist">Action Bar Checklist</h2> |
| 340 | |
| Roman Nurik | 7379046 | 2011-12-22 16:18:19 -0800 | [diff] [blame] | 341 | <p>When planning your split action bars, ask yourself questions like these:</p> |
| 342 | <h4>How important is view navigation to the task?</h4> |
| 343 | <p>If view navigation is very important to your app, use tabs (for fastest view-switching) or spinners.</p> |
| 344 | <h4>Which of the app's actions need to be consistently available directly from the action bar, and which can be moved to the action overflow?</h4> |
| 345 | <p>Use the <acronym title="Frequent, Important or Typical">FIT</acronym> scheme to decide if actions |
| 346 | are displayed at the top-level or can be moved to the action overflow. If the number of top-level |
| 347 | actions exceeds the capacity of the main action bar, display them separately in a bottom action bar.</p> |
| 348 | <h4>What else is important enough to warrant continuous display?</h4> |
| 349 | <p>Sometimes it is important to display contextual information for your app that's always visible. |
| 350 | Examples are the number of unread messages in a messaging inbox view or the Now Playing information |
| 351 | in a music player. Carefully plan which important information you would like to display and |
| 352 | structure your action bars accordingly.</p> |