If a screen shows more than one interactive item in the same location, it can be difficult for a user to interact with the app. It also becomes difficult for some accessibility services, such as Switch Access, to clearly represent the actionable items to the user.
When you implement
OnLongClickListeners, check if the clickable
View has an ancestor or descendant that's clickable and shares the same on-screen location. In a well-implemented user interface, clickable items appear separately.
Consider the following when implementing clickable
Button, are denoted as clickable by default. In your app, if the
Viewis not clickable, or does not perform an action when clicked, remove its
android:clickable="false". In this way, you tell accessibility services to consider the
- In more complex user interfaces, multiple clickable
Viewsmay have parent/child relationships in the view hierarchy. In cases of nested clickable
Views, implement click handling so that only one
Viewhandles clicks for any single action.
The purpose of each clickable item should be clear, and a user should be able to reasonably anticipate the action that will be performed by clicking or long-clicking an item. These actionable items should also be of an appropriate size for touch targets.
To manually verify that an app's user interface doesn't contain duplicate clickable items:
- Turn on Switch Access for Android and set up two-switch step scanning.
- Open the app.
- Use the switch assigned to the “Next” action to move switch access focus item-by-item through the interface.
- If any item appears to be focused more than once, the interface may contain duplicate clickable items.
Android's automated testing tools can detect duplicate clickable
Views. 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.