Adding Accessibility to Views: Android

Robin Kamboj
3 min readAug 13, 2017

--

By having made an application to production, you are now targeting nearly 90%-95% of the people in the region of publish. The remaining nearly 5% of the people are the ones suffering from one sort of physical disability or another- colour blindness, weak eyesight, handicaps, etc. For any application to gain trust and respect of all kinds of their customers, it is crucial that you also design for accessible apps.

In this post, you will learn how to build accessible apps in a series of steps to target the audience with disabilities. The following are the ways by which you can do the same:

  1. For static views with constant values like textviews with never changing text, like toolbar headers, heading textviews, etc, you are required to add contentDescription attribute in xml, whose value will be a string describing the view.
  2. For views with animations like switch, radio buttons, etc whose value will can change on selecting/deselecting them, you have to provide initial state contentDescription in xml, for example: “switch OFF state” when by default switch is off at the first render. In addition, you have to add state listeners to such views to listen to whether they are selected (view.setContentDescription(“ON state achieved”) or deselected (view.setContentDescription(“OFF state achieved”).
  3. Making large touch targets is also a requirement that is achieved when you provide attributes for minWidth as 48dp and minHeight as 48dp for all your potentially small views.
  4. Providing high contrast is required for people with low vision and those who use devices with dimmed displays. By providing increased contrast ratios between the foreground and background colours in your app, you make it easier for users to navigate within and between screens.To help developers use sufficient contrast ratios in their apps, The World Wide Web Consortium (W3C) has created a set of colour contrast accessibility guidelines:
  • For large text, 18 points or higher for regular text and 14 points or higher for bold text, you should use a contrast ratio of at least 3.0 to 1.
  • For small text, smaller than 18 points for regular text and smaller than 14 points for bold text, you should use a contrast ratio of at least4.5 to 1.
  • To check your contrast ratios, you can use the Accessibility Scanner or one of the many contrast checkers available online.

5. Using cues other than colour: To assist users with colour vision deficiencies, use cues other than colour to distinguish UI elements within your app’s screens. These techniques could include using different shapes or sizes, providing text or visual patterns, or adding audio- or touch-based (haptic) feedback to mark the elements’ differences.

6. focusable views: One can add focusable (boolean) attribute to views like RelativeLayout, say, containing a number of TextViews with text attributes. Setting focusable as true will put out a single announcement to all the sub-announcements of the contained TextViews. You can specify the android:contentDescription XML attribute on a container to override automatic grouping and ordering of contained items.

7. nextFocusUp and nextFocusDown: These attributes are added to views to determine which view will be “focused/spoken” next or previous.

8. Making your custom views accessible: I had previously written another post on how to make your own custom views accessible. You may check it out here.

Theses were nearly all the checks that you should assure to include in your app in order to make it accessible to the remaining audience for your app. The quest for something big always begins with taking baby steps, consider this one too!

I hope this post was of useful context to you. If it was, please hit the heart ❤ for this post. And as usual, happy programming. :)

--

--

Robin Kamboj

Software Engineer by profession. Designer by force. Bibliophile by nature.