Android 简明教程

Android - UI Patterns

在本章中,我们将研究可用于 Android 来设计行为一致且可预见的应用程序的不同 UI 模式。

In this chapter we will look at the different UI Patterns which are available by android to design apps that behave in a consistent and foreseeable way.

UI Patterns components

一个好的 Android 应用程序应遵循以下 UI 模式 −

A good android application should follow following UI patterns −

  1. Action Bar

  2. Confirming and Acknowledging

  3. Settings

  4. Help

  5. Selection

接下来,我们将详细讨论上述的 UI 模式。

Now we will discuss the above mentioned UI Patterns in detail.

Action Bar

操作栏是每个屏幕顶部的专栏,通常在整个应用程序中保持稳定。它提供了一些主要功能,如下所示:

The action bar is a dedicated bar at the top of each screen that is generally persistent throughout the app. It provides you several key function which are as following −

  1. Makes important actions prominent and accessible

  2. Supports consistent navigation and view switching within apps

  3. Reduces clutter by providing an action overflow for rarely used actions

  4. Provides a dedicated space for giving your app an identity

Action Bar Components

操作栏有四个主要组件,可在下图中看到。

Action Bar has four major components which can be seen in the following image.

ui patterns 1

这些组件的名称和功能如下所述:

These components name and functionality is discussed below −

Sr.No

Action Bar Components

1

App Icon The app icon establishes your app’s identity. It can be replaced with a different logo or branding if you wish.

2

View control If your app displays data in different views, this segment of the action bar allows users to switch views.

3

Action buttons Show the most important actions of your app in the actions section.

4

Action overflow Move less often used actions to the action overflow.

Confirming and Acknowledging

当用户在应用程序的 UI 上调用某个操作时,这是一个 confirmacknowledge 通过一个土司或一个对话框完成该操作的好方法。

When a user invokes a action on your app’s UI, it is a good practice to confirm or acknowledge that action through a toast or a dialog box.

确认和应答之间有差异。

There is a difference between Confirming and Acknowledging.

Confirming

当我们要求用户验证他们是否真正希望继续执行他们刚刚调用的某个操作时,这称为确认。如您在以下图片中看到的:

When we ask the user to verify that they truly want to proceed with a action that they just invoked, it is called confirming. As you can see in the following image −

ui patterns 2

Acknowledging

当我们显示一个土司,让用户知道他们刚刚调用的操作已完成,则称为应答,如您在以下图片中看到的:

When we display a toast to let the user know that the action they just invoked has been completed, this is called acknowledging, As you can see in the following image −

ui patterns 3

Settings

在您的应用程序中,用户可以表明他们希望应用程序如何运作的偏好所在的地方称为设置。设置的使用可以以下面的方式使您的应用程序用户受益:

The place in your app where users can indicate their preferences for how your app should behave is called as Settings. The use of settings can benefit your app’s users in the following ways −

  1. Settings help user to predetermine that what will happen in certain situations

  2. Use of settings in your app help users to feel in control

Placement of Settings

安卓开发人员更倾向于始终将“设置”选项作为上述操作溢出的组成部分。由于用户不经常使用该选项,因此常见做法是将其放置在“帮助”之外的所有其他项下方。如下所示 −

It is preferred by the android developers to always make "settings" option part of action overflow which is mentioned above. As users did not frequently use this option so the common practice is to place it below all other items except "Help". As you can see in the following picture −

ui patterns 4

Help

部分应用用户在使用你的应用程序时可能会遇到一些困难,他们会希望找到一些答案,并希望在应用程序内获得答案。因此,应始终将“帮助”作为应用程序的一部分。

Some of your app users may run into some difficulty while using your app and they will be looking for some answers, and they want them within the app. So always make "help" part of your app.

Placement of Help

与“设置”类似,“帮助”选项的标准放置设计位于 action overflow 。始终将其作为菜单中的最后一项,并始终将其标记为“帮助”。即使应用程序屏幕没有其他操作溢出项,“帮助”也应出现在那里。如下所示 −

Like "Settings" the standard design of placing "Help" option is in action overflow. Always make it very last item in the menu and always label it "Help". Even if your app screen has no other action overflow items, "Help" should appear there. As you can see this in the following picture −

ui patterns 5

Selection

安卓 3.0 版本将长按手势更改为全局手势以选择数据。长按手势现用于选择数据,将背景操作和所选数据的选择管理功能合并到一个新的元素 contextual action bar (CAB) 中。

Android 3.0 version changed the long press gesture to the global gesture to select data. The long press gesture is now used to select data, combining contextual actions and selection management functions for selected data into a new element called the contextual action bar (CAB).

Using Contextual Action Bar (CAB)

所选 CAB 栏是一个临时操作栏,在选择数据时会覆盖应用当前的操作栏。在用户长时间按可选择数据项后,它才会出现。如下所示 −

The selection CAB is a temporary action bar that overlays your app’s current action bar while data is selected. It appears after the user long presses on a selectable data item. As you can see in the following picture −

ui patterns 6

用户可以从 CAB 栏执行以下操作 −

From the CAB bar user can perform following actions −

  1. Select additional data items by touching them

  2. Trigger an action from the CAB that applies to all highlighted data items

  3. Dismiss the CAB via the navigation bar’s Back button or the CAB’s checkmark button