无障碍开发清单

Making an application accessible is about a deep commitment to usability, getting the details right and delighting your users. This document provides a checklist of accessibility requirements, recommendations and considerations to help you make sure your application is accessible. Following this checklist does not guarantee your application is accessible, but it's a good place to start.

对应用进行无障碍优化是对应用的易用性、更精确的获取细节、取悦用户等方面更深层次的延伸。该文档提供了无障碍需求、建议和注意事项的清单,可以帮助开发者确保应用程序无障碍。遵循该清单,不能保证应用无障碍,但却是个通往无障碍的开端。

Creating an accessible application is not just the responsibility of developers. Involve your design and testing folks as well, and make them are aware of the guidelines for these other stages of development:

创建无障碍应用并不只是开发者的责任,需要将设计和测试小组加入进来,让他们了解应用开发其他阶段的无障碍指南:

In most cases, creating an accessible Android application does not require extensive code restructuring. Rather, it means working through the subtle details of how users interact with your application, so you can provide them with feedback they can sense and understand. This checklist helps you focus on the key development issues to get the details of accessibility right.

在大多数案例中,创建android无障碍应用并不需要严格的代码重构。相反,无障碍优化作用于用户如何与应用程序交互的微妙细节,开发者可以提供给用户可以感知和理解的反馈。该清单帮助开发者专注于主要的开发问题,保证应用的无障碍细节正确。

无障碍需求

The following steps must be completed in order to ensure a minimum level of application accessibility.

必须完成以下步骤来保证应用最低级别的无障碍特性。

  1. Describe user interface controls: Provide content descriptions for user interface components that do not have visible text, particularly ImageButton, ImageView and CheckBox components. Use the android:contentDescription XML layout attribute or the setContentDescription(CharSequence) method to provide this information for accessibility services. (Exception: decorative graphics)
    描述用户界面控件:为没有视觉文本的用户界面组件提供内容描述,特别是图像按钮(ImageButton),图像视图( ImageView)和复选框(CheckBox)组件。使用XML布局属性android:contentDescription或者使用setContentDescription(CharSequence)方法来为无障碍服务提供内容描述。(例外:装饰性图像
  2. Enable focus-based navigation: Make sure users can navigate your screen layouts using hardware-based or software directional controls (D-pads, trackballs, keyboards and navigation gestures). In a few cases, you may need to make user interface components focusable or change the focus order to be more logical for user actions.
    保证基于焦点的导航:保证用户在使用基于硬件或软件定向控制(D-pads,轨迹球,键盘和导航手势)时,可以导航屏幕布局。在一些情况下,需要保证用户界面可聚焦,或者改变焦点顺序使用户交互更具逻辑性。
  3. Custom view controls: If you build custom interface controls for your application, implement accessibility interfaces for your custom views and provide content descriptions. For custom controls that are intended to be compatible with versions of Android back to 1.6, use the Support Library to implement the latest accessibility features.
    自定义视图控件:如果为应用程序创建了自定义界面控件,为自定义视图 实现无障碍接口并提供内容描述。对于需要与android最低版本1.6保持一致性的自定义控件,使用支持库(Support Library)实现最新的无障碍特性。
  4. No audio-only feedback: Audio feedback must always have a secondary feedback mechanism to support users who are deaf or hard of hearing. For example, a sound alert for the arrival of a message must be accompanied by a system Notification, haptic feedback (if available) or other visual alert.
    纯音频反馈替代:音频反馈必须有第二种反馈机制来支持听障用户的使用。例如,消息铃声作为系统通知必须伴随触觉反馈(如果可能的话)或其他视觉警告。
  5. Test: Test accessibility by navigating your application using directional controls, and using eyes-free navigation with TalkBack enabled. For more accessibility testing information, see the Accessibility Testing Checklist.
    测试:使用定向控制导航android应用,和使用TalkBack提供的非视觉导航来测试无障碍性能。更多关于无障碍测试的信息,详见无障碍测试清单

无障碍建议

The following steps are recommended for ensuring the accessibility of your application. If you do not take these actions, it may impact the overall accessibility and quality of your application.

以下步骤被推荐用来确保应用程序无障碍。如果不执行这些操作,这可能会影响应用程序整体的无障碍和质量。

  1. Android Design Accessibility Guidelines: Before building your layouts, review and follow the accessibility guidelines provided in the Design guidelines.
    Android设计无障碍指南:在创建布局前,复查和遵守设计指南中提供的无障碍方案。
  2. Framework-provided controls: Use Android's built-in user interface controls whenever possible, as these components provide accessibility support by default.
    框架提供的控件:尽可能使用Android标准用户界面控件,这些控件默认提供无障碍支持。
  3. Temporary or self-hiding controls and notifications: Avoid having user interface controls that fade out or disappear after a certain amount of time. If this behavior is important to your application, provide an alternative interface for these functions.
  4. 临时或自我隐藏控件和通知:避免使用一段时间之后,变暗或消失的用户界面控件。如果该功能对应用很重要,为该功能提供一个替代的交互方式。

特殊情况和注意事项

The following list describes specific situations where action should be taken to ensure an accessible app. Review this list to see if any of these special cases and considerations apply to your application, and take the appropriate action.

以下列表描述了需要采取措施保证应用无障碍的特殊情况。检查此列表,查看这些特殊情况和注意事项是否适用于正在开发的应用程序,如果适用,请执行相应的操作。

  1. Text field hints: For EditText fields, provide an android:hint attribute instead of a content description, to help users understand what content is expected when the text field is empty and allow the contents of the field to be spoken when it is filled.
    文本区域提示:对于EditText区域,使用android:hint属性代替内容描述,当文本区域为空的时候帮助用户了解期望输入的内容,当EditText被填充时,允许填充内容被朗读出。
  2. Custom controls with high visual context: If your application contains a custom control with a high degree of visual context (such as a calendar control), default accessibility services processing may not provide adequate descriptions for users, and you should consider providing a virtual view hierarchy for your control using AccessibilityNodeProvider.
    高视觉特性的自定义控件:如果应用程序包含一个具有高视觉特性的自定义控件(例如日历控件),默认无障碍服务处理不会为用户提供充足的内容描述,开发者可以考虑使用AccessibilityNodeProvider为控件提供虚拟视图层次
  3. Custom controls and click handling: If a custom control in your application performs specific handling of user touch interaction, such as listening with onTouchEvent(MotionEvent) for MotionEvent.ACTION_DOWN and MotionEvent.ACTION_UP and treating it as a click event, you must trigger an AccessibilityEvent equivalent to a click and provide a way for accessibility services to perform this action for users. For more information, see Handling custom touch events.
    自定义控件和点击处理:如果应用中的自定义控件操作手势特殊,例如使用onTouchEvent(MotionEvent)监听MotionEvent.ACTION_DOWNMotionEvent.ACTION_UP ,并作为点击事件对待,开发者必须触发一个等效于点击的AccessibilityEvent,并为用户无障碍服务提供一种方式模拟执行这项操作。更多信息,详见“处理自定义触摸事件”。
  4. Controls that change function: If you have buttons or other controls that change function during the normal activity of a user in your application (for example, a button that changes from Play to Pause), make sure you also change the android:contentDescription of the button appropriately.
    有功能改变的控件:如果用户在正常使用应用的过程中,应用中的按钮或其他控件的功能会发生改变(例如,一个按钮从播放变为暂停),保证按钮的android:contentDescription会相应改变。
  5. Prompts for related controls: Make sure sets of controls which provide a single function, such as the DatePicker, provide useful audio feedback when an user interacts with the individual controls.
    相关联控件提示:提供独立功能的一组控件,例如日期选择器(DatePicker),当用户与相关联控件中的个别控件交互的时候,提供有效的音频反馈。
  6. Video playback and captioning: If your application provides video playback, it must support captioning and subtitles to assist users who are deaf or hard of hearing. Your video playback controls must also clearly indicate if captioning is available for a video and provide a clear way of enabling captions.
    视频播放和字幕:如果应用程序提供视频播放,必须为聋人和重听用户提供字幕和注释来帮助他们理解。视频播放控件必须明确说明字幕是否可用,并提供简单的方式启用字幕。
  7. Supplemental accessibility audio feedback: Use only the Android accessibility framework to provide accessibility audio feedback for your app. Accessibility services such as TalkBack should be the only way your application provides accessibility audio prompts to users. Provide the prompting information with a android:contentDescription XML layout attribute or dynamically add it using accessibility framework APIs. For example, if your application takes action that you want to announce to a user, such as automatically turning the page of a book, use the announceForAccessibility(CharSequence) method to have accessibility services speak this information to the user.
    补充无障碍音频反馈:仅使用Android无障碍框架为应用程序提供无障碍音频反馈。像TalkBack类的无障碍服务应该是为应用提供无障碍音频反馈的唯一方式。使用android:contentDescription XML布局属性或使用无障碍框架APIs动态地添加该属性来为应用提供提示信息。例如,如果开发者想要把应用程序执行的操作告知用户,如书籍自动翻页功能,使用announceForAccessibility(CharSequence)方法让无障碍服务为用户读出该信息。
  8. Custom controls with complex visual interactions: For custom controls that provide complex or non-standard visual interactions, provide a virtual view hierarchy for your control using AccessibilityNodeProvider that allows accessibility services to provide a simplified interaction model for the user. If this approach is not feasible, consider providing an alternate view that is accessible.
    复杂视觉交互的自定义控件:对于提供复杂或非标准视觉交互的自定义控件,使用AccessibilityNodeProvider为自定义控件提供虚拟视图层次AccessibilityNodeProvider允许无障碍服务为用户提供简化交互模型。如果该方式不可行,考虑提供一个无障碍的替代视图。
  9. Sets of small controls: If you have controls that are smaller than the minimum recommended touch size in your application screens, consider grouping these controls together using a ViewGroup and providing a android:contentDescription for the group.
    小控件组:如果控件比推荐的触摸尺寸小,可以考虑使用ViewGroup将这些控件组合起来,并使用android:contentDescription为该组合提供内容描述。
  10. Decorative images and graphics: Elements in application screens that are purely decorative and do not provide any content or enable a user action should not have accessibility content descriptions.
    装饰性图像和图形:应用屏幕中的不提供任何内容或用户无法操作的纯装饰性元素,不应该为这些元素提供无障碍内容描述。