Home | History | Annotate | Download | only in ui_guidelines
      1 page.title=Menu Design Guidelines
      2 @jd:body
      3 	
      4 <div id="qv-wrapper">
      5 <div id="qv">
      6 			
      7 <h2>Menu design quickview</h2>
      8 
      9 <ul>
     10   <li>An Options menu is for any commands that are global to the current activity. </li>
     11   <li>A Context menu is for any commands that apply to the current selection. </li>
     12   <li>Place the most frequently used operations first. </li>
     13   <li>Put only the most important commands fixed on the screen. </li>
     14   <li>The commands on the Context menu that appears when you touch &amp; hold on an item should be duplicated on the activity you get to by a normal press on that item.
     15 </ul>
     16 
     17 
     18 <h2>In this document</h2>
     19 
     20 <ol>
     21   <li><a href=#tour_of_the_menus>Tour of the Menus</a>
     22 	<ol>
     23        <li style="padding-top: 4px;"><a href=#options_menu>Options Menu</a></li>
     24        <li style="padding-top: 4px;"><a href=#context_menu>Context Menu</a></li>
     25        <li style="padding-top: 4px;"><a href=#comparison_of_options_and_context_menus>Comparison of Options &amp; Context Menus</a></li>
     26        <li style="padding-top: 4px;"><a href=#commands_fixed>Commands Fixed in an Activity Screen</a></li>
     27 	</ol>
     28   </li>
     29   <li><a href=#guidelines>Guidelines</a>
     30 	<ol>
     31        <li style="padding-top: 4px;"><a href=#separate_commands>Separate specific from global commands</a></li>
     32        <li style="padding-top: 4px;"><a href=#most_frequently_used>Place most frequently used first</a></li>
     33        <li style="padding-top: 4px;"><a href=#dont_put_commands>Don't put commands <em>only</em> in a Context menu</li>
     34        <li style="padding-top: 4px;"><a href=#first_in_context_menu>First command in Context menu should be most intuitive</li>
     35        <li style="padding-top: 4px;"><a href=#selecting_content_item>Selecting an item should perform most intuitive operation</a></li>
     36        <li style="padding-top: 4px;"><a href=#context_menu_should_identify>A Context menu should identify the selected item</li>
     37        <li style="padding-top: 4px;"><a href=#most_important_commands>Put only most important commands fixed on the screen</a></li>
     38        <li style="padding-top: 4px;"><a href=#short_names>Use short names in Options icon menu</a></li>
     39        <li style="padding-top: 4px;"><a href=#a_dialog_should_not_have_an_options_menu>A dialog should not have Options menu</a></li>
     40        <li style="padding-top: 4px;"><a href=#do_not_substitute_message>If no Options menu, don't display message</a></li>
     41        <li style="padding-top: 4px;"><a href=#dim_hide_menu_items>Dim or hide menu items not available</a></li>
     42 	</ol>
     43   </li>
     44 </ol>
     45 
     46 <h2>See also</h2>
     47 
     48 <ol>
     49   <li><a href="http://android-developers.blogspot.com/2008/12/touch-mode.html">Touch mode</a></li>
     50   <li><a href="{@docRoot}guide/practices/ui_guidelines/activity_task_design.html">Activity and Task Design</a></li>
     51 </ol>
     52 
     53 </div>
     54 </div>       
     55 
     56 <p>
     57   A menu holds a set of commands (user actions) that are normally hidden, and
     58   are accessible by a button, key, or gesture.  Menu commands provide a means
     59   for performing operations and for navigating to other parts of your 
     60   application or other applications.  Menus are useful for freeing screen space,
     61   as an alternative to placing functionality and navigation, in buttons or other
     62   user controls in the content area of your application. 
     63 </p>
     64 
     65 <p>
     66   The Android system provides two types of menus you can use to provide
     67   functionality or navigation. Between them, you should be able to organize
     68   the functionality and navigation for your application.  Briefly:
     69   <ul>
     70     <li>The <em>Options menu</em> contains primary functionality that applies
     71         globally to the current activity or starts a related activity. 
     72         It is typically invoked by a user pressing a hard button, often labeled MENU.</li>
     73     <li>The <em>Context menu</em> contains secondary functionality for the currently
     74         selected item.  It is typically invoked by a user's touch &amp; hold
     75         on an item.  Like on the Options menu, the operation can run either
     76         in the current or another activity.</li>
     77   </ul>
     78 </p>
     79 
     80 <p>
     81   All but the simplest applications have menus.  The system automatically
     82   lays the menus out and provides standard ways for users to access them.  
     83   In this sense, they are familiar and dependable ways for users to access
     84   functionality across all applications.  All menus are panels that "float"
     85   on top of the activity screen and are smaller than full screen, so that the
     86   application is still visible around its edges.  This is a visual reminder 
     87   that a menu is an intermediary operation that disappears once it's used.
     88 </p>
     89 
     90 <p>
     91   Let's start out with a quick tour of the menus.
     92 </p>
     93 
     94 <h2 id="tour_of_the_menus">Tour of the Menus</h2>
     95 
     96 <p class="note"><strong>Note:</strong> Your menus and screens might not look 
     97 like those shown in this document; they may vary from one version of Android 
     98 or device to another.
     99 </p>
    100 
    101 <h3 id="options_menu">Options Menu</h3>
    102 
    103 <p>
    104   The Options menu contains commands that apply globally across the current
    105   activity, or can start another activity. They do not apply to a selected
    106   item in the content (a <a href="#context_menu">Context menu</a> does that).  
    107 </p>
    108 
    109 <p>
    110   On most devices, a user presses the MENU button to access the Options menu, 
    111   as shown in the screenshot below.  To close the menu, the user presses 
    112   MENU again, or presses the BACK button. 
    113   In fact, to cancel out of any menu, press the BACK button.  (Pressing the MENU
    114   button or touching outside the menu also works.)  Note that how to invoke this
    115   menu may be different on different devices.
    116 </p>
    117 
    118 <p>
    119   Each
    120   <a href="{@docRoot}guide/practices/ui_guidelines/activity_task_design.html#activities">activity</a>
    121   activity has its own set of operations and therefore its own Options menu.
    122   An application with multiple activities would have a different Options menu 
    123   for each activity. 
    124 </p>
    125 
    126 <p>
    127   For example, in the message list view of an email program, the Options menu
    128   might let you search the messages, compose a new message, refresh the list, 
    129   or change the email settings.  The compose view of an email program would 
    130   have a different Options menu, such as adding a CC field, attaching a file, 
    131   or discarding the message.
    132 </p>
    133 
    134 <p id="options_icon_expanded_menus">
    135   In order to handle a large number of menu items, the Options menu
    136   progressively discloses them in two steps:
    137 </p>
    138 
    139 <ul>
    140   <li>
    141     <b>Options icon menu</b> - The first press of the MENU button displays a
    142     non-scrollable grid of icons at the bottom of the screen.  (On the G1
    143     phone, up to 6 buttons typically appear.)
    144   </li>
    145   <li>
    146     <b>Options expanded menu</b> - If the activity has more menu items than will
    147     fit on the icon menu, then the last icon is labeled "More" &mdash; selecting it
    148     displays a list that can contain any number of menu items and will scroll 
    149     as necessary.
    150   </li>
    151 </ul>
    152 
    153 <img src={@docRoot}images/menu_design/MenuDiagram.png>
    154 
    155 <p>
    156   On some versions of Android, the user can display keyboard shortcuts in the
    157   icon menu by long pressing the MENU button &mdash; the text in the icon menu
    158   alternates between the command names and their keyboard shortcuts (if any).
    159 </p>
    160 
    161 <h3 id="context_menu">Context Menu</h3>
    162 
    163 <p>
    164   A Context menu is similar to a right-click context menu in a desktop
    165   operating system.  It is normally a shortcut that duplicates commands
    166   found elsewhere.
    167 </p>
    168 
    169 <p>
    170   A user can touch &amp; hold on content on the screen to
    171   access a Context menu (if one exists), as shown in the screenshot below. 
    172   A Context menu is a list of menu items (commands) that can operate
    173   on the selected content.  The command can either be part of the current
    174   activity, or the system can pass the selected content along to 
    175   an operation in another activity (by way of an 
    176   <a href="{@docRoot}guide/practices/ui_guidelines/activity_task_design.html#intents">intent</a>).
    177 </p>
    178 
    179 <p>
    180   For example, in an email message list, a user can touch &amp; hold on
    181   an email message to open a Context menu containing commands to read,
    182   archive, or delete the message. 
    183 </p>
    184 
    185 <p id="location">
    186   A user can also touch &amp; hold a <em>location</em> on the screen to
    187   access a Context menu.  An example is when the user does touch &amp; hold
    188   on a blank spot on the Home screen, a Context menu appears; selecting
    189   an item from that menu inserts an icon at that location.
    190 </p>
    191 
    192 <img src={@docRoot}images/menu_design/ContextMenuDiagram.png>
    193 
    194 <h4 id="context_menu_shortcut">Context Menu is a Shortcut</h4>
    195 
    196 <p>
    197   In the above example, if the user performs touch &amp; hold on the contact
    198   "Obi Wan Kenobi", a Context menu opens.  The commands provided in
    199   this Context menu are the complete set of actions that can be performed
    200   on this contact. 
    201 </p>
    202 
    203 <p>
    204   A normal touch on an item in the content activates the most intuitive
    205   command for that selection &mdash; in this case, "View contact".
    206   We recommend that the most intuitive command also be listed as the
    207   first item in the Context menu.  In this example, selecting the contact
    208   "Obi Wan Kenobi" runs the same command "View contact" that is listed
    209   at the top of the Context menu.
    210 </p>
    211 
    212 <p>
    213   Also note, as shown in the following screenshot, the Context menu and the
    214   next screen both hold the same complete set of commands that can be performed
    215   on this contact.  The Context menu displays the commands in a list, 
    216   while the "View contact" activity splits them into various items in the
    217   Options menu, icon buttons and list items.
    218 </p>
    219 
    220 <p>
    221   Because of this duplication, using the Context menu is considered a <em>shortcut</em>
    222   for going to the next screen and performing the operation there.  Context menus
    223   are less discoverable than either buttons fixed on-screen or the Options menu.
    224   Many users never discover or use Context menus.  It is for this reason that, for
    225   the most part, any command on a Context menu should also appear on the most
    226   intuitive operation's screen.  As the next section explains, text operations,
    227   such as "Select text" might appear only on a Context menu.  Also, rich
    228   applications, such as browsers, which themselves can contain web applications,
    229   may have commands on Context menus that are not available elsewhere.
    230 </p>
    231 
    232 <img src={@docRoot}images/menu_design/ContextMenuViewContactDiagram.png>
    233 
    234 <h4>Text Commands in Context Menu</h4>
    235 
    236 <p>
    237   Text links and text fields in the content both have system-provided operations 
    238   that are common across all applications: operations such as "Select all", "Select text",
    239   "Copy all", and "Add to dictionary".  If the text field is editable, it also 
    240   has  other operations, such as "Cut all" and "Input Method", and if text 
    241   is also on the clipboard, it has "Paste".  The system automatically inserts
    242   the appropriate menu items into the Context menu of text links and text
    243   fields, as shown in the following screenshot.
    244 </p>
    245 
    246 <img src={@docRoot}images/menu_design/TextFieldContextMenuDiagram.png>
    247 
    248 
    249 <h3 id="comparison_of_options_and_context_menus">Comparison of Options and Context Menus</h3>
    250 
    251 <p>
    252 	An Options menu holds commands that are global to the activity while a
    253 	Context menu holds commands that apply only to an item in the content.
    254     As shown in these diagrams, the user navigates to the menu, then
    255     touches a menu item to perform an action or open a dialog.
    256 </p>
    257 
    258 <img src={@docRoot}images/menu_design/TaskFlowDiagram.png>
    259 
    260 <p>
    261   For more technical information on menus, see
    262   <a href="{@docRoot}guide/topics/ui/menus.html">Creating Menus</a>.
    263 </p>
    264 
    265 <h3 id="commands_fixed">Commands Fixed in an Activity Screen</h4>
    266 
    267 <p>
    268   Commands can also be fixed directly on screen, typically in
    269   text buttons, graphic buttons, or list items.  This placement is by far the most
    270   discoverable location for commands &mdash; a user can immediately see the command
    271   without having to first press a button.  This increased visibility needs to be
    272   weighed against the space such user controls take up, or the sense that they
    273   might clutter the visual design.
    274 </p>
    275 
    276 <h2 id="guidelines">Guidelines</h2>
    277 
    278 <p>
    279   Selecting the right kind of menu to present, and using menus
    280   consistently, are critical factors in good application design. The following
    281   guidelines should assist user experience designers and application developers
    282   toward this end.
    283 </p>
    284 
    285 <h3 id="separate_commands">Separate selection-specific commands from global commands</h3>
    286 
    287 <p>
    288   Put any commands that are global to the current activity in the Options menu
    289   or place them fixed in an activity screen; put commands that apply to the
    290   current selection in the Context menu.  (In any case, the command
    291   could either run as part of this activity or start another activity.)
    292 </p>
    293 
    294 <p>
    295   You can determine in which menu to place a command by what it operates on:
    296   If the command acts on selected content (or a particular
    297   <a href="#location">location</a>) on the screen, put the command in the
    298   Context menu for that content.  If the command acts on no specific content
    299   or location, put it in the Options menu.  This separation of commands
    300   is enforced by the system in the following way.  When you press the MENU
    301   button to display the Options menu, the selected content becomes unselected,
    302   and so cannot be operated on.  For an explanation
    303   of why the content becomes unselected, see the article on
    304   <a href="http://android-developers.blogspot.com/2008/12/touch-mode.html">Touch mode</a>.
    305 </p>
    306 
    307 <p>
    308   An example of a selection-specific Context menu is when a user performs a
    309   touch &amp; hold on a person's name in a list view of a contacts application.
    310   The Context menu would typically contain commands "View contact", "Call contact",
    311   and "Edit contact".  
    312 </p>
    313 
    314 <h3 id="most_frequently_used">Place the most frequently used operations first</h3>
    315 
    316 <p>
    317   Because of limited screen height, some menus may be scrollable, so it's
    318   important to place the most important commands so they can be viewed without
    319   scrolling.  In the case of the Options menu, place the most frequently used
    320   operation on its <a href="#options_icon_expanded_menus">icon menu</a>;
    321   the user will have to select "More" to see the rest.
    322   It's also useful to place similar commands in the same location &mdash;
    323   for example, the Search icon might always be the first icon in the Options
    324   menu across several activities that offer search.
    325 </p>
    326 
    327 <p>
    328   In a Context menu, the most intuitive command should be first, followed
    329   by commands in order of decreasing use, with the least used command at the bottom.
    330 </p>
    331 
    332 <h3 id="dont_put_commands">Don't put commands <em>only</em> in a Context menu</h3>
    333 <p>
    334   If a user can fully access your application without using Context menus, 
    335   then it's designed properly!  In general, if part of your application is inaccessible
    336   without using Context menus, then you need to duplicate those commands elsewhere.
    337 </p>
    338 
    339 <p>
    340   Before opening a Context menu, it has no visual representation that identifies
    341   its presence (whereas the Options menu has the MENU button), and so is not
    342   particularly discoverable. 
    343   Therefore, in general, a Context menu should <em>duplicate</em> commands 
    344   found in the corresponding activity screen.  For example, while it's useful to
    345   let the user call a phone number from a Context menu invoked by touch
    346   &amp; hold on a name in a list of contacts, that operation should <em>also</em>
    347   be available by the user touching the phone number itself when viewing contact details.
    348   See <a href="#context_menu_shortcut">shortcut</a> for an illustration of this example.
    349 </p>
    350 
    351 <h3 id="first_in_context_menu">The first command in a Context menu should be the selection's most intuitive command</h3>
    352 
    353 <p>
    354   As described under <a href="#context_menu_shortcut">shortcut</a>,
    355   touching on an item in the content should activate the same command as touching
    356   the first item in the Context menu.  Both cases should be the most intuitive
    357   operation for that item.  
    358 </p>
    359 
    360 <h3 id="selecting_content_item">Selecting an item in the content should perform the most intuitive operation</h3>
    361 
    362 <p>
    363   In your application, when the user touches any actionable text (such as a link
    364   or list item) or image (such as a photo icon), execute the operation most
    365   likely to be desired by the user.
    366 </p>
    367 
    368 <p>
    369   Some examples of primary operations:
    370 </p>
    371 
    372 <ul>
    373     <li>Selecting an image executes "View image"</li>
    374     <li>Selecting a media icon or filename executes "Play"</li>
    375     <li>Selecting a URL link executes "Open link"</li>
    376     <li>Selecting an address executes "Go to address" (in a maps application)</li>
    377 </ul>
    378 
    379 <p>
    380   Note that selecting the same item in different contexts might invoke
    381   different operations:
    382 </p>
    383 
    384 <ul>
    385     <li>In a contact application, selecting a contact executes "View details"</li>
    386     <li>In an IM application, selecting a contact executes "Start chat"</li>
    387     <li>In an Email application, when adding a recipient to the "To" field
    388         through the contact book, selecting a contact executes "Add to recipient
    389         list"</li>
    390 </ul>
    391 
    392 
    393 <h3 id="context_menu_should_identify">A Context menu should identify the selected item</h3>
    394 
    395 <p>
    396   When a user does touch &amp; hold on an item, the Context menu should 
    397   contain the name of the selected item.  Therefore, 
    398   when creating a Context menu, be sure to include a title and the name of the
    399   selected item so that it's clear to the user what the context is.  
    400   For example, if a user selects a contact "Joan of Arc", put that name in the
    401   title of the Context menu (using
    402   {@link android.view.ContextMenu#setHeaderTitle(java.lang.CharSequence) setHeaderTitle}). 
    403   Likewise, a command to edit the contact should be called "Edit contact",
    404   not just "Edit".
    405 </p>
    406 
    407 
    408 <h3 id="most_important_commands">Put only the most important commands fixed on the screen</h3>
    409 
    410 <p>
    411   By putting commands in menus, you free up the screen to hold more content. 
    412   On the other hand, fixing commands in the content area of an activity
    413   makes them more prominent and easy to use.
    414 </p>
    415 
    416 <p>
    417   Here are a number of important reasons to place commands fixed on the activity screen:
    418 </p>
    419 
    420   <ul>
    421     <li>
    422       To give a command the highest prominence, ensuring the command is obvious and won't be overlooked.<br>
    423       Example: A "Buy" button in a store application.
    424     </li>
    425     <li> 
    426       When quick access to the command is important and going to the menu would be
    427       tedious or slow.<br>
    428       Example: Next/Previous buttons or Zoom In/Out buttons in an image viewing application.
    429     </li>
    430     <li>
    431       When in the middle of an operation that needs to be completed.<br>
    432       Example: Save/Discard buttons in an image crop activity.
    433     </li>
    434     <li>
    435       Dialogs and wizards.<br>
    436       Example: OK/Cancel buttons
    437     </li>
    438     <li>
    439       For direct manipulation.<br>
    440       Example: Dragging an icon in the Home screen to the trash
    441     </li>
    442   </ul>
    443 
    444 <h3 id="short_names">Use short names in the Options icon menu</h3>
    445 
    446 <p>
    447   If a text label in the <a href="#options_icon_expanded_menus">Options icon menu</a>
    448   is too long, the system truncates it in the middle.  Thus, "Create Notification"
    449   is truncated to something like "Createication". You have no control over
    450   this truncation, so the best bet is to keep the text short.  In some versions of Android,
    451   when the icon is highlighted by a navigation key (such as a trackball), the
    452   entire descriptive text may be shown as a marquee, where the words are
    453   readable as they scroll by.  <!--For more information, see the Text Guidelines
    454   [update link].-->
    455 </p>
    456 
    457 <h3 id="a_dialog_should_not_have_an_options_menu">A dialog should not have an Options menu</h3>
    458 
    459 <p>
    460   When a dialog is displayed, pressing the MENU button should do nothing.  This also holds true
    461   for activities that look like dialogs.  A dialog box is recognizable by being
    462   smaller than full-screen, having zero to three buttons, is non-scrollable, and 
    463   possibly a list of selectable items that can include checkboxes or radio buttons.
    464   <!--For examples of dialogs, see Text Guidelines.-->
    465 </p>
    466 
    467 <p>
    468   The rationale behind not having a menu is that when a dialog is displayed, the user is in
    469   the middle of a procedure and should not be allowed to start a new global task
    470   (which is what the Option menu provides).
    471 </p>
    472 
    473 <h3 id="do_not_substitute_message">If an activity has no Options menu, do not display a message</h3>
    474 
    475 <p>
    476   When the user presses the MENU button, if there is no Options menu, the system
    477   currently does nothing.  We recommend you do not perform any action (such as
    478   displaying a message).  It's a better user experience for this behavior to be
    479   consistent across applications.
    480 </p>
    481 
    482 
    483 
    484 <h3 id="dim_hide_menu_items">Dim or hide menu items that are not available in the current context</h3>
    485 
    486 <p>
    487   Sometimes a menu item's action cannot be performed &mdash; for example,
    488   the "Forward" button in a browser cannot work until after the "Back" 
    489   button has been pressed. We recommend:
    490 </p>
    491 
    492 <ul>
    493   <li> 	
    494     <b>In Options menu</b> - disable the menu item, which dims the text and icon,
    495     turning it gray.  This applies to menu items in both the icon menu and the
    496     "More" menu.  It would be disorienting for the icon menu to change from 6
    497     items to 5 items, and we treat the "More" menu the same way.
    498   </li>
    499   <li>
    500     <b>In Context menu</b> - hide the menu item.  This makes the menu shorter so the
    501     user sees only available choices (which also reduces any scrolling).
    502   </li>
    503 </ul>
    504 
    505 </body>
    506 </html>
    507 
    508