Alternatives on Android

I’ve always felt that making native apps accessible is slightly easier than websites partly because they’re more streamlined in terms of their UX but also because you’re only dealing with one programming language. If you’re looking for an easy place to start making your app accessible you can give it a boost by adding text alternatives for images, buttons and other meaningful UI elements.

Text alternatives have a dual benefit as they’re not only the hook that Talkback users need to understand your app but also the hook needed for automated testing  with tools such as Lint.  For this reason it’s not unusual to see apps where the alternatives are written for devs and testing purposes – such as ‘app_button’ rather than being human readable text alternatives such as ‘Submit’. This should be avoided; text alternatives are for users not testers.

To add text alternatives on Android use contentDescription:

<Button
    android:id=”@+id/submit_button”
    android:src=”@drawable/submit”
    android:contentDescription=”@string/submit”/>

For elements that change state such as an add/remove button use setContentDescription method to edit the alternative at runtime:

String contentDescription = "Select " + strValues[position];
label.setContentDescription(contentDescription);

For decorative images the contentDescription should be set to ‘null’:

android:contentDescription=”@null”

contentDescription should not be used for labelling form inputs – editText fields. The description is only read before the text field is populated by the user and lost altogether if the field is populated or cleared by the user. The next best option is to use the android:hint attribute. Like contentDescription, android:hint will be announced when the field is empty but ignored when the field is populated. Unlike contentDescription however it will be announced if the user clears the form input.

This is still not an ideal user experience and can be confusing for Talkback users who want to verify what form input is what when checking a form before it is submitted. A more robust technique is to use the LabelFor property which allows a visible label to be associated with an EditText box. This will be announced regardless of whether the input field is empty or populated with text. If a visible label is not possible (although I’d recommend against that) you can make the label invisible so it doesn’t change your visual layout.

Resources

 

4 thoughts on “Alternatives on Android

  1. Pingback: Android aps with unlabelled buttons cause blind users real trouble | inclusivesociety

  2. Hey Hugh, thanks back at you for your post. Have you thought about contacting the British Radio app people and sharing your feedback?

  3. Pingback: 31st July, 2015 – Weekly Accessibility round-up | ServeOM Inclusion

Comments are closed.