Home | History | Annotate | Download | only in patterns
      1 page.title=Action Bar
      2 page.tags="actionbar","navigation"
      3 page.metaDescription=The Action bar is an essential design element for all apps. Learn about what the action bar can do and how to use it in your apps.
      4 @jd:body
      5 
      6 <img src="{@docRoot}design/media/action_bar_pattern_overview.png">
      7 
      8 <a class="notice-developers" href="{@docRoot}guide/topics/ui/actionbar.html">
      9   <div>
     10     <h3>Developer Docs</h3>
     11     <p>Action Bar</p>
     12   </div>
     13 </a>
     14 
     15 
     16 <p>The <em>action bar</em> is a dedicated piece of real estate at the top of each screen that is generally persistent throughout the app.</p>
     17 <p><strong>It provides several key functions</strong>:</p>
     18 <ul>
     19   <li>Makes important actions prominent and accessible in a predictable way (such as <em>New</em> or <em>Search</em>).</li>
     20   <li>Supports consistent navigation and view switching within apps.</li>
     21   <li>Reduces clutter by providing an action overflow for rarely used actions.</li>
     22   <li>Provides a dedicated space for giving your app an identity.</li>
     23 </ul>
     24 <p>If you're new to writing Android apps, note that the action bar is one of the most important design elements you can implement. Following the guidelines described here will go a long way toward making your app's interface consistent with the core Android apps.</p>
     25 <h2 id="organization">General Organization</h2>
     26 
     27 <p>The action bar is split into four different functional areas that apply to most apps.</p>
     28 <img src="{@docRoot}design/media/action_bar_basics.png">
     29 
     30 <div class="layout-content-row">
     31   <div class="layout-content-col span-7 with-callouts">
     32 
     33     <ol>
     34       <li class="value-1"><h4>App icon</h4>
     35         <p>
     36 
     37 The app icon establishes your app's identity. It can be replaced with a different logo or branding
     38 if you wish.
     39 Important: If the app is currently not displaying the top-level screen, be sure to display the Up
     40 caret to the left of the app icon, so the user can navigate up the hierarchy. For more discussion of
     41 Up navigation, see the <a href="{@docRoot}design/patterns/navigation.html">Navigation</a> pattern.
     42         </p>
     43 
     44 <img src="{@docRoot}design/media/action_bar_pattern_up_app_icon.png">
     45 <div class="figure-caption">
     46   App icon with and without "up" affordance.
     47 </div>
     48 
     49       </li>
     50     </ol>
     51 
     52   </div>
     53   <div class="layout-content-col span-6 with-callouts">
     54 
     55     <ol>
     56       <li class="value-2"><h4>View control</h4>
     57         <p>
     58 
     59 If your app displays data in different views, this segment of the action bar allows users to switch
     60 views. Examples of view-switching controls are drop-down menus or tab controls. For more information on view-switching, see the <a href="{@docRoot}design/patterns/app-structure.html">App Structure</a> pattern.
     61 
     62         </p>
     63         <p>
     64 
     65 If your app doesn't support different views, you can also use this space to display non-interactive
     66 content, such as an app title or longer branding information.
     67 
     68         </p>
     69       </li>
     70       <li class="value-3"><h4>Action buttons</h4>
     71         <p>
     72 
     73 Show the most important actions of your app in the actions section. Actions that don't fit in the
     74 action bar are moved automatically to the action overflow. Long-press on an icon to view the action's name.
     75 
     76         </p>
     77       </li>
     78       <li class="value-4"><h4>Action overflow</h4>
     79         <p>
     80 
     81 Move less often used actions to the action overflow.
     82 
     83         </p>
     84       </li>
     85     </ol>
     86   </div>
     87 </div>
     88 
     89 <h2 id="adapting-rotation">Adapting to Rotation and Different Screen Sizes</h2>
     90 
     91 <p>One of the most important UI issues to consider when creating an app is how to adjust to screen
     92 rotation on different screen sizes.</p>
     93 <p>You can adapt to such changes by using <em>split action bars</em>, which allow you to distribute action bar
     94 content across multiple bars located below the main action bar or at the bottom of the screen.</p>
     95 
     96 <img src="{@docRoot}design/media/action_bar_pattern_rotation.png">
     97 <!-- <div class="figure-caption">
     98   Split action bar showing action buttons at the bottom of the screen in vertical orientation.
     99 </div> -->
    100 
    101 <h2 id="considerations-split-action-bars">Layout Considerations for Split Action Bars</h2>
    102 
    103 <div class="layout-content-row">
    104   <div class="layout-content-col span-8 with-callouts">
    105 
    106 <p>When splitting up content across multiple action bars, you generally have three possible locations
    107 for action bar content:</p>
    108 <ol>
    109 <li><strong>Main action bar</strong></li>
    110 <li><strong>Top bar</strong></li>
    111 <li><strong>Bottom bar</strong></li>
    112 </ol>
    113 <p>If the user can navigate up the hierarchy from a given screen, the main action bar contains the up
    114 caret, at a minimum.</p>
    115 <p>To allow the user to quickly switch between the views your app provides, use tabs or a spinner in
    116 the top bar.</p>
    117 <p>To display actions and, if necessary, the action overflow, use the bottom bar.</p>
    118 
    119   </div>
    120   <div class="layout-content-col span-5">
    121 
    122     <img src="{@docRoot}design/media/action_bar_pattern_considerations.png">
    123 
    124   </div>
    125 </div>
    126 
    127 <h2 id="ActionButtons">Action Buttons</h2>
    128 <p><em>Action buttons</em> on the action bar surface your app's most important activities. Think about which
    129 buttons will get used most often, and order them accordingly. Depending on available screen real
    130 estate, the system shows your most important actions as action buttons and moves the rest to the
    131 action overflow. The action bar should show only those actions that are available to the user. If an action is unavailable in the current context, hide it. Do not show it as disabled.</p>
    132 
    133 <img src="{@docRoot}design/media/action_bar_pattern_action_icons.png">
    134 <div class="figure-caption">
    135   A sampling of action buttons used throughout the Gmail application.
    136 </div>
    137 
    138 <p>For guidance on prioritizing actions, use the FIT scheme.</p>
    139 
    140 <div class="layout-content-row">
    141   <div class="layout-content-col span-4">
    142 
    143 <p><strong>F &mdash; Frequent</strong></p>
    144 <ul>
    145 <li>Will people use this action at least 7 out of 10 times they visit the screen?</li>
    146 <li>Will they typically use it several times in a row?</li>
    147 <li>Would taking an extra step every time truly be burdensome?</li>
    148 </ul>
    149 
    150   </div>
    151   <div class="layout-content-col span-4">
    152 
    153 <p><strong>I &mdash; Important</strong></p>
    154 <ul>
    155 <li>Do you want everyone to discover this action because it's especially cool or a selling point?</li>
    156 <li>Is it something that needs to be effortless in the rare cases it's needed?</li>
    157 </ul>
    158 
    159   </div>
    160   <div class="layout-content-col span-4">
    161 
    162 <p><strong>T &mdash; Typical</strong></p>
    163 <ul>
    164 <li>Is it typically presented as a first-class action in similar apps?</li>
    165 <li>Given the context, would people be surprised if it were buried in the action overflow?</li>
    166 </ul>
    167 
    168   </div>
    169 </div>
    170 
    171 <p>If either F, I, or T apply, then it's appropriate for the action bar. Otherwise, it belongs in the
    172 action overflow.</p>
    173 
    174 <p>
    175 
    176 Pre-defined glyphs should be used for certain common actions such as "refresh" and "share." The
    177 download link below provides a package with icons that are scaled for various screen densities and
    178 are suitable for use with the Holo Light and Holo Dark themes. The package also includes unstyled
    179 icons that you can modify to match your theme, in addition to Adobe&reg; Illustrator&reg; source
    180 files for further customization.
    181 
    182 </p>
    183 <p>
    184 
    185 <a onClick="ga('send', 'event', 'Design', 'Download', 'Action Bar Icons (@actionbar page)');"
    186    href="{@docRoot}downloads/design/Android_Design_Icons_20131106.zip">Download the Action Bar Icon Pack</a>
    187 
    188 </p>
    189 
    190 <div class="layout-content-row">
    191   <div class="layout-content-col span-6">
    192 
    193 <h4>Action overflow</h4>
    194 <p>The action overflow in the action bar provides access to your app's less frequently used actions.
    195 The overflow icon only appears on phones that have no menu hardware keys. Phones with menu keys
    196 display the action overflow when the user presses the key.</p>
    197 
    198   </div>
    199   <div class="layout-content-col span-7">
    200 
    201     <img src="{@docRoot}design/media/action_bar_pattern_overflow.png">
    202     <div class="figure-caption">
    203       Action overflow is pinned to the right side.
    204     </div>
    205 
    206   </div>
    207 </div>
    208 
    209 <p>How many actions will fit in the main action bar? Action bar capacity is controlled by the following
    210 rules:</p>
    211 <ul>
    212 <li>Action buttons in the main action bar may not occupy more than 50% of the bar's width. Action
    213   buttons on bottom action bars can use the entire width.</li>
    214 <li>The screen width in density-independent pixels
    215   (<acronym title="Density-independent pixels. One dp is one pixel on a 160 dpi screen.">dp</acronym>)
    216   determine the number of items that will fit in the main action bar:<ul>
    217 <li>smaller than 360 dp = 2 icons</li>
    218 <li>360-499 dp = 3 icons</li>
    219 <li>500-599 dp = 4 icons</li>
    220 <li>600 dp and larger = 5 icons</li>
    221 </ul>
    222 </li>
    223 </ul>
    224 
    225 <img src="{@docRoot}design/media/action_bar_pattern_table.png">
    226 <div class="figure-caption">
    227   In the above table "o" denotes an action bar item and "=" an overflow icon.
    228 </div>
    229 
    230 <h4>Sharing data</h4>
    231 <p>Whenever your app permits sharing of data, such as images or movie clips, use a <em>share action
    232 provider</em> in your action bar. The share action provider is designed to speed up sharing by
    233 displaying the most recently used sharing service next to a spinner button that contains other
    234 sharing options.</p>
    235 
    236 <img src="{@docRoot}design/media/action_bar_pattern_share_pack.png">
    237 <div class="figure-caption">
    238   The Gallery app's share action provider with extended spinner for additional sharing options.
    239 </div>
    240 
    241 <h2 id="contextual">Contextual Action Bars</h2>
    242 
    243 <p>A <em>contextual action bar (CAB)</em> is a temporary action bar that overlays the app's action bar for the
    244 duration of a particular sub-task. CABs are most typically used for tasks that involve acting on
    245 selected data or text.</p>
    246 
    247 <img src="{@docRoot}design/media/action_bar_cab.png">
    248 <div class="figure-caption">
    249   Contextual action bar in Browser and Gmail
    250 </div>
    251 
    252 <p>The selection CAB appears after a long press on a selectable data item triggers selection mode.</p>
    253 <p><strong>From here the user can</strong>:</p>
    254 <ul>
    255 <li>Select additional elements by touching them.</li>
    256 <li>Trigger an action from the CAB that applies to all selected data items. The CAB then
    257    automatically dismisses itself.</li>
    258 <li>Dismiss the CAB via the navigation bar's Back button or the CAB's checkmark button. This removes
    259    the CAB along with all selection highlights.</li>
    260 </ul>
    261 <p>Use CABs whenever you allow the user to select data via long press. You can control the action
    262 content of a CAB in order to insert the actions you would like the user to be able to perform.</p>
    263 <p>For more information, refer to the <a href="{@docRoot}design/patterns/selection.html">Selection
    264 pattern</a>.</p>
    265 
    266 
    267 
    268 <h2 id="checklist">Action Bar Checklist</h2>
    269 
    270 <p>When planning your split action bars, ask yourself questions like these:</p>
    271 <h4>How important is view navigation to the task?</h4>
    272 <p>If view navigation is very important to your app, use tabs (for fastest view-switching) or spinners.</p>
    273 <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>
    274 <p>Use the <acronym title="Frequent, Important or Typical">FIT</acronym> scheme to decide if actions
    275 are displayed at the top-level or can be moved to the action overflow. If the number of top-level
    276 actions exceeds the capacity of the main action bar, display them separately in a bottom action bar.</p>
    277 <h4>What else is important enough to warrant continuous display?</h4>
    278 <p>Sometimes it is important to display contextual information for your app that's always visible.
    279 Examples are the number of unread messages in a messaging inbox view or the Now Playing information
    280 in a music player. Carefully plan which important information you would like to display and
    281 structure your action bars accordingly.</p>