Posted By: Nav Singh
Today we will learn accessibility in general and how to implement and test it in our applications.
It is about making sure that users who have limited vision or other physical impairments can use your application.
Impact of accessibility
- Increase your app’s reach
According to the World Bank, 15% of the world’s population has some type of disability. People with disabilities depend on apps and services that support access to communicate, learn, and work.
- Improve your app’s versatility
Accessibility can make it easier for all users to interact with your app, not only those with disabilities.
How Android enables accessibility
One of the main ways that Android enables accessibility is by allowing users to hear spoken feedback that announces the content of user interface components as they interact with applications.
How to make your application accessible
- Task flows: Design well-defined, clear task flows with minimal navigation steps.
- Action target size: Make sure buttons and selectable areas are of sufficient size for users to easily touch them, especially for critical actions. How big? (48dp (roughly 9mm) or larger).
- Label user interface: Label user interface components that do not have visible text.
- Enable focus-based navigation: Make sure users can navigate your screen layouts using hardware-based or software directional controls (D-pads, trackballs, and keyboards).
- Add label to decorative views like Imageview:
- If the
viewis there just for the decorative purpose you can skip it when users accessing your app using accessibility tools e.g. Talkback:
android:contentDescription="@null" OR android:importantForAccessibility="no"
- Setting text as the heading:
// only avaialble for API 28 or higher android:accessibilityHeading="true"
- Set the view to be focusable for ScreenReader:
// only avaialble for API 28 or higher android:screenReaderFocusable="true"
- Set the navigation between views:
↓ android:nextFocusDown="@id/textview_2" ← android:nextFocusLeft="view id" ↑ android:nextFocusUp="view id" → android:nextFocusRight="view id"
- Set Textview as a label for any other field e.g. EditText:
- Set how accessibility services process the view changes:
android:accessibilityLiveRegion="none || assertive || polite"
- Process the view as a single group:
// add the following properties to the parent tag android:focusable="true" OR // only avaialble for API 28 or higher android:screenReaderFocusable="true"
The colors of your app’s interface affect how easily users can read and understand it. So make sure that there is a sufficient color contrast that makes text and images easier to read and understand.
- In your app’s user interface, specify background and foreground colors with sufficient color contrast.
android:backgroundto define foreground and background colors with a high contrast ratio.
The W3C recommends:
- At least 4.5:1 for small text (below 18 points regular or 14 points bold)
- At least 3.0:1 for large text (18 points and above regular or 14 points and above bold)
Test your app’s accessibility
- Manual testing: Interact with your app using Android accessibility services.
- Testing with analysis tools: Use tools to discover opportunities to improve your app’s accessibility(Talkback, Accessibility scanner)
- Automated testing: Turn on accessibility testing in
- User testing: Get feedback from real people who interact with your app.
- Pre-launch report on Google Play
Check full sample code
- Accessibility scanner