Users of accessibility services, such as screen readers, rely on text labels to interact with user interfaces.
Typically, a screen reader user moves focus from item to item, listening to the label of each item as focus moves. If a user interface contains multiple elements with the same text label, it can be difficult for the user to distinguish between distinct elements.
When implementing a user interface, carefully consider the text labels in the interface. Each element should have a unique text label that describes its visual meaning, purpose, or associated action.
Pay particular attention to layouts that are reused in an interface. For example, layouts used as rows within
RecyclerViews are often inflated repeatedly. In such a case, the repeated labels should include additional text with more identifying information or context for the description of the item.
The purpose of each clickable element should be clear, and a user should be able to anticipate the action that will result from selecting an actionable element.
When defining text labels for interface elements:
- Ensure that the label for each element is distinct.
- Ensure that labels for repeated content (such as items in repeated list rows) include text qualifying or further describing the item to which they refer. For example, if the interface includes multiple "Delete" buttons, include additional text in the labels, such as "Delete item 4."
To manually verify that an app's user interface doesn't contain duplicate descriptions:
- Turn on TalkBack.
- Open the app.
- Use linear navigation gestures to move accessibility focus to each element on the screen.
- If TalkBack reads the same description for more than one item, the interface may contain duplicate descriptions.
Android's automated testing tools can detect duplicate descriptions. Consider using Accessibility Scanner for Android for manual testing of your app on-device. For automated tests, turn on accessibility checking in Espresso and Robolectric.