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