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