In today’s post, I’ll be making you familiar with some amazing features of android app accessibility thanks to Amanda Cline, a proficient android app developer with a brilliant caliber of building simple and complex websites and web applications.
And sure, Android offers a lot of accessibility options and features. The sad part is that they are usually neglected during the design and implementation phase. The extent is such that even though accessibility APIs were first introduced in Android 1.6, developers were neither familiar nor interested in them.
The extent of accessibility being an afterthought can be gauged by the fact that it produces only a limited number of results and mentions on Google search and Stack Overflow.
This shouldn’t be the case as implementing accessibility features is actually quite a simple task. Let’s delve deeper into how we accomplish that:
Table of Contents
Adding a text description to UI elements
All good designers are aware of the fact that a well designed interface is self-explanatory and intuitive. Users do not require instructions for performing actions. However, this may not be the case always.
Visually impaired users need audio help and physically impaired ones might need visual cues to navigate even the most simple interfaces. The content descriptions are utilized in this regard. Apart from being the easiest accessibility feature to implement, they are the most useful ones too. They are similar to the comments in a program.
Google suggests that content descriptions must be mainly used for image view, image button and checkbox elements as this is where they are most needed.
These descriptions can be added in two ways, via XML layouts or traditional Java methods.
The following allows you to add descriptions to images in two ways:
<ImageView android:id="@+id/new_image" ... android:contentdescription="@string/image_desc" />
The @string has to be declared in strings.xml file in the following fashion:
<string name="image_desc">Simple description of what the image represents</string>
In case of edit text fields use the following lines to make the user understand as to what they should type.
android:hint = "Name Field"
If the interface elements in your app are changing states, like a toggle button or a checkbox, you must ensure that the content description, depending on the state, changes dynamically.
In such a case you must use the setContentDescription() method.
label.setContentDescription(“Toggle is set to: ” + (ToggleButton).isChecked())
If it’s not necessary, do not add description otherwise you may end up annoying users.
In case you think that the element is self explanatory or does not have a real function, like an app icon maybe, then use:
This feature is also called “Focus navigation” and allows the user to use a particular application using digital controllers, without the need for a touchscreen. It is imperative that your Android application supports these mechanisms for navigation.
One must make sure that each input element, can be focussed and is clickable using directional buttons. Also, keep in mind that you must visually indicate the element that the user is focussing on, by having it highlighted.
By default, all control elements in Android have this feature enabled. However, if you have created your own elements, you must make them come “in-focus” using the setFocusable (true) method or the android:focusable attribute:
<EditText ... android:focusable = "true" />
Android’s algorithms can find the nearest focusable element, helping users navigate the interface intuitively with the directional controller. In case you must override this feature, you can use the XML attributes below: android:nextFocusDown, android:nextFocusLeft, android:nextFocusRight, android:nextFocusUp The code below will further shed some light into their usage:
<EditText android:id = "@+id/upper_text_field" … ... android:nextFocusDown = "@+id/lower_text_field" />
Building your own accessibility service:
The accessibility service carries out communication with the user, on behalf of the application. Moreover, it provides navigational feedback such as : text to speech, visual cues etc.
Again, by default, Android by default provides some really cool services such as TalkBack and Explore by touch. This comes off as immense help to users who find it difficult to interact with the device normally owing to physical disabilities or situational ones : ex driving, exercising etc.
The best part is that as a developer you can build your own accessibility services for your application and bundle them together or as a standalone app.
Testing for accessibility
Testing is equally important as implementation, sometimes maybe more. One must ensure that they have thoroughly tested their apps after implementing accessibility features. One way to do so is by enabling Talkback and Explore by touch. You must navigate your application using just audio feedback and directional controls. Some noteworthy aspects are:
- Making sure that every control element provides the necessary feedback
- Audio prompts are not repetitive
- They are not longer than required
Also, Android guidelines require you to have every focusable element at least 48dp in length and width.
Additionally, in order to support those users with hearing disabilities, you must accompany all audio feedback with a secondary mechanism such as haptic feedback, visual cues such as pop ups and notifications. In case your application has video playback, you must offer them subtitles or caption support.
Through this post, we come to know the importance of accessibility and why you must have it in your development timeline.
Also this post guides you on how to implement different features into an Android app. Regardless of how a user interacts with a device, all developers must focus on making their apps accessible by everyone.