Android设计和开发系列第二篇:Action Bar(Design)

Action Bar

The action bar is a dedicated piece of real estate at the top of each screen that is generally persistent throughout the app.

It provides several key functions:

  • Makes important actions prominent and accessible in a predictable way (such as New or Search).
  • Supports consistent navigation and view switching within apps.
  • Reduces clutter by providing an action overflow for rarely used actions.
  • Provides a dedicated space for giving your app an identity.

If you‘re new to writing Android apps, note that the action bar is one of the most important design elements you can implement. Following the guidelines described here will go a long way toward making your app‘s interface consistent with the core Android apps.

General Organization



The action bar is split into four different functional areas that apply to most apps.

  1. App icon

    The app icon establishes your app‘s identity. It can be replaced with a different logo or branding if you wish. Important: If the app is currently not displaying the top-level screen, be sure to display the Up caret to the left of the app icon, so the user can navigate up the hierarchy. For more discussion of Up navigation, see the Navigation pattern.

    App icon with and without "up" affordance.

  1. View control

    If your app displays data in different views, this segment of the action bar allows users to switch views. Examples of view-switching controls are drop-down menus or tab controls. For more information on view-switching, see the App Structure pattern.

    If your app doesn‘t support different views, you can also use this space to display non-interactive content, such as an app title or longer branding information.

  2. Action buttons

    Show the most important actions of your app in the actions section. Actions that don‘t fit in the action bar are moved automatically to the action overflow. Long-press on an icon to view the action‘s name.

  3. Action overflow

    Move less often used actions to the action overflow.

Adapting to Rotation and Different Screen Sizes



One of the most important UI issues to consider when creating an app is how to adjust to screen rotation on different screen sizes.

You can adapt to such changes by using split action bars, which allow you to distribute action bar content across multiple bars located below the main action bar or at the bottom of the screen.

Layout Considerations for Split Action Bars


When splitting up content across multiple action bars, you generally have three possible locations for action bar content:

  1. Main action bar
  2. Top bar
  3. Bottom bar

If the user can navigate up the hierarchy from a given screen, the main action bar contains the up caret, at a minimum.

To allow the user to quickly switch between the views your app provides, use tabs or a spinner in the top bar.

To display actions and, if necessary, the action overflow, use the bottom bar.

Action Buttons



Action buttons on the action bar surface your app‘s most important activities. Think about which buttons will get used most often, and order them accordingly. Depending on available screen real estate, the system shows your most important actions as action buttons and moves the rest to the action overflow. The action bar should show only those actions that are available to the user. If an action is unavailable in the current context, hide it. Do not show it as disabled.

A sampling of action buttons used throughout the Gmail application.

For guidance on prioritizing actions, use the FIT scheme.

F — Frequent

  • Will people use this action at least 7 out of 10 times they visit the screen?
  • Will they typically use it several times in a row?
  • Would taking an extra step every time truly be burdensome?

I — Important

  • Do you want everyone to discover this action because it‘s especially cool or a selling point?
  • Is it something that needs to be effortless in the rare cases it‘s needed?

T — Typical

  • Is it typically presented as a first-class action in similar apps?
  • Given the context, would people be surprised if it were buried in the action overflow?

If either F, I, or T apply, then it‘s appropriate for the action bar. Otherwise, it belongs in the action overflow.

Pre-defined glyphs should be used for certain common actions such as "refresh" and "share." The download link below provides a package with icons that are scaled for various screen densities and are suitable for use with the Holo Light and Holo Dark themes. The package also includes unstyled icons that you can modify to match your theme, in addition to Adobe® Illustrator® source files for further customization.

Download the Action Bar Icon Pack

Action overflow

The action overflow in the action bar provides access to your app‘s less frequently used actions. The overflow icon only appears on phones that have no menu hardware keys. Phones with menu keys display the action overflow when the user presses the key.

Action overflow is pinned to the right side.

How many actions will fit in the main action bar? Action bar capacity is controlled by the following rules:

  • Action buttons in the main action bar may not occupy more than 50% of the bar‘s width. Action buttons on bottom action bars can use the entire width.
  • The screen width in density-independent pixels (dp) determine the number of items that will fit in the main action bar:
    • smaller than 360 dp = 2 icons
    • 360-499 dp = 3 icons
    • 500-599 dp = 4 icons
    • 600 dp and larger = 5 icons

In the above table "o" denotes an action bar item and "=" an overflow icon.

Sharing data

Whenever your app permits sharing of data, such as images or movie clips, use a share action provider in your action bar. The share action provider is designed to speed up sharing by displaying the most recently used sharing service next to a spinner button that contains other sharing options.

The Gallery app‘s share action provider with extended spinner for additional sharing options.

Contextual Action Bars



contextual action bar (CAB) is a temporary action bar that overlays the app‘s action bar for the duration of a particular sub-task. CABs are most typically used for tasks that involve acting on selected data or text.

Contextual action bar in Browser and Gmail

The selection CAB appears after a long press on a selectable data item triggers selection mode.

From here the user can:

  • Select additional elements by touching them.
  • Trigger an action from the CAB that applies to all selected data items. The CAB then automatically dismisses itself.
  • Dismiss the CAB via the navigation bar‘s Back button or the CAB‘s checkmark button. This removes the CAB along with all selection highlights.

Use CABs whenever you allow the user to select data via long press. You can control the action content of a CAB in order to insert the actions you would like the user to be able to perform.

For more information, refer to the Selection pattern.

Action Bar Checklist



When planning your split action bars, ask yourself questions like these:

How important is view navigation to the task?

If view navigation is very important to your app, use tabs (for fastest view-switching) or spinners.

Which of the app‘s actions need to be consistently available directly from the action bar, and which can be moved to the action overflow?

Use the FIT scheme to decide if actions are displayed at the top-level or can be moved to the action overflow. If the number of top-level actions exceeds the capacity of the main action bar, display them separately in a bottom action bar.

What else is important enough to warrant continuous display?

Sometimes it is important to display contextual information for your app that‘s always visible. Examples are the number of unread messages in a messaging inbox view or the Now Playing information in a music player. Carefully plan which important information you would like to display and structure your action bars accordingly.

时间: 2024-10-13 12:06:30

Android设计和开发系列第二篇:Action Bar(Design)的相关文章

Android设计和开发系列第二篇:Action Bar(Develop—Training)

Adding the Action Bar GET STARTED DEPENDENCIES AND PREREQUISITES Android 2.1 or higher YOU SHOULD ALSO READ Action Bar Implementing Effective Navigation DESIGN GUIDE Action Bar The action bar is one of the most important design elements you can imple

Android设计和开发系列第二篇:Action Bar(Develop—API Guides)

Action Bar IN THIS DOCUMENT Adding the Action Bar Removing the action bar Using a logo instead of an icon Adding Action Items Handling clicks on action items Using split action bar Navigating Up with the App Icon Adding an Action View Handling collap

Android设计和开发系列第二篇:Navigation Drawer(Design)

Navigation Drawer Creating a Navigation Drawer The navigation drawer is a panel that transitions in from the left edge of the screen and displays the app’s main navigation options. Displaying the navigation drawer The user can bring the navigation dr

Android设计和开发系列第一篇:Notifications通知(Design)

Design篇 Notifications DEVELOPER DOCS Notifying the User NOTIFICATIONS IN ANDROID 4.4 AND LOWER VIDEO DevBytes: Notifications in the Android L Developer Preview The notification system allows users to keep informed about relevant and timely events in

Android设计和开发系列第一篇:Notifications通知(Develop—API Guides)

Notifications IN THIS DOCUMENT Design Considerations Creating a Notification Required notification contents Optional notification contents and settings Notification actions Notification priority Creating a simple notification Applying an expanded lay

Android设计和开发系列第一篇:Notifications通知(Develop)

Develop篇 Building a Notification PREVIOUSNEXT THIS LESSON TEACHES YOU TO Create a Notification Builder Define the Notification's Action Set the Notification's Click Behavior Issue the Notification YOU SHOULD ALSO READ Notifications API Guide Intents

Android Metro风格的Launcher开发系列第二篇

前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客Android Metro风格的Launcher开发系列第一篇写了如何配置Android开发环境,只是用文字和图片展示了开发Metro风格Launcher的初步设计和产品要求,这一篇文章将会从代码上讲解如何实现对应的UI效果,好了,评书开讲! Launcher主体框架实现: Launcher主体框架我选用的是大家所熟悉的ViewPager控件,因为ViewPager

【转载】Android Metro风格的Launcher开发系列第二篇

前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客Android Metro风格的Launcher开发系列第一篇写了如何配置Android开发环境,只是用文字和图片展示了开发Metro风格Launcher的初步设计和产品要求,这一篇文章将会从代码上讲解如何实现对应的UI效果,好了,评书开讲! Launcher主体框架实现: Launcher主体框架我选用的是大家所熟悉的ViewPager控件,因为ViewPager

chromium浏览器开发系列第二篇:如何编译最新chromium源码

说一下为什么这么晚才发第二篇,上周和这周department的工作太多了,晚上都是十点半从公司出发,回家以后实在没有多余的精力去摸键盘了.所以请大家包涵! 上期回顾: chromium源码下载: 1.找个靠谱的vpn(我试过了,网上说的不用vpn拿代码的都不靠谱): 2.获取depot_tools,解压,设置环境变量; 3.gclient获取python和git,svn,设置环境变量: 4.fetch–nohooks chromium –nosvn=true 获取源码: 5.gclientsyn