ImageView Name

Link to ImageView Name copied to clipboard

WCAG 2.0 - 1.1.1 A Impact - Critical

ImageView elements must provide a name.

Supported within:
XML Layouts

Impact

People that use TalkBack will be the most impacted by issues found. If an ImageView provides information to users with vision and doesn't provide a name, TalkBack will not announce anything, and that information is missing for user experiences with TalkBack.

Informative images should utilize contentDescription to provide any necessary context and details through TalkBack.

Confirmation

  1. Turn on TalkBack
  2. Perform a "touch to explore" gesture on the control
  3. For informative images:
    • Accessible: Receives focus and announces a meaningful description.


    For decorative images:
    • Accessible: Does not receive focus individually. Within a group is accepted.

How to Fix

Native Android

ImageView image = .......; // Role: Image
image.setContentDescription("Tasty Chocolates"); // Name: Tasty Chocolates.

React Native

important

React Native does not add the accessibility role automatically to many elements. Be sure to add accessibilityRole="image" to all images you want to be available to assistive technology. The axe Accessibility Linter VSCode Extension and axe DevTools Linter now include React Native support which can help you catch bugs like these prior to UI testing.

  • If the image portrays information the user needs, give it a descriptive accessibilityLabel to relay that information, and set the accessible property to true:
<Image
    ...
    accessible={true}
    accessibilityLabel="A chai tea latte in a white mug with a newspaper behind it."
/>
  • If the image does not portray unique information, such as a background or decorative image, make it not focusable:
<Image
    ...
    accessible={false}
/>