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