Accessibility

Labeling User Interface Elements

许多用户界面控制依赖于可视化的线索(提示)来表征它的意义和用途。例如,笔记本应用利用ImageButton 附上一个图片标记,用以指示用户添加一个笔记。

 一个编辑框EditText组件附近可能有一个标签表示它的用途。 对于实力不好的人,这些都没啥用处。

利用android:contentDescription XML 布局属性可以使这些控制更容易获取。如果用户启用辅助语音功能,当用户导航到这个控制,文本被播放出来。

For this reason, set the android:contentDescription attribute for every ImageButtonImageView,CheckBox in your application's user interface, and add descriptions to any other input controls that might require additional information for users who are not able to see it.

For example, the following ImageButton sets the content description for the plus button to the add_note string resource, which could be defined as “Add note" for an English language interface:

<ImageButton
    android:id=”@+id/add_note_button”
    android:src=”@drawable/add_note”
    android:contentDescription=”@string/add_note”/>
通过包含这个描述,辅助功能能够提供语音反馈,发出“Add note” 当用户moves focus to this button or hovers over it 。

Note: 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. When the field is filled, TalkBack reads the entered content to the user, instead of the hint text.


Building Accessible Custom Views

If your application requires a custom view component, you must do some additional work to ensure that your custom view is accessible. These are the main tasks for ensuring the accessibility of your view:

Handling directional controller clicks
Implementing accessibility API methods
Accessibility events 是用户与应用中可视化界面组件交互产生的messages。Accessibility Services 用于处理这些消息,并利用时间中的信息形成补充的反馈和提示。Android4.0 and higher, the methods of accessibility events have been expanded to provide more detailed information.  The expanded accessibility methods are part of the  View  class as well as the  View.AccessibilityDelegate  class. The methods are as follows:

sendAccessibilityEvent()
(API Level 4) This method is called when a user takes action on a view. The event is classified with a user action type such as  TYPE_VIEW_CLICKED. You typically do not need to implement this method unless you are creating a custom view.
sendAccessibilityEventUnchecked()
(API Level 4) This method is used when the calling code needs to directly control the check for accessibility being enabled on the device ( AccessibilityManager.isEnabled()). If you do implement this method, you must perform the call as if accessibility is enabled, regardless of the actual system setting. You typically do not need to implement this method for a custom view.
dispatchPopulateAccessibilityEvent()
(API Level 4) The system calls this method when your custom view generates an accessibility event. As of API Level 14, the default implementation of this method calls  onPopulateAccessibilityEvent() for this view and then the  dispatchPopulateAccessibilityEvent() method for each child of this view. In order to support accessibility services on revisions of Android  prior to 4.0 (API Level 14) you  must override this method and populate  getText() with descriptive text for your custom view, which is spoken by accessibility services, such as TalkBack.





    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值