Accessibility Scanner Remediation

Link to Accessibility Scanner Remediation copied to clipboard

Is your team using Google's Android Accessibility Scanner?

This section will provide remediation advice for the rules that the scanner checks for. Read more on leveraging Accessibility Scanner and axe DevTools Mobile.

Visit Google's Accessibility Scanner guidelines for their full list of current checks, descriptions, and updates.

Content Labeling

Item Label Missing

Content within the view may be missing contextual information.

For any view that provides information to the user, provide one of the following to resolve this accessibility issue:

  • android:contentDescription: In most cases, adding a content description is all that is needed.
  • android:hint: Hints can be added to describe the type of data the user should enter for editable text views.
  • android:labelFor: This tag will allow you to assign a view as a label for another view.
note

Within Compose, content description and hint are found as a parameter when defining the view or through the Modifier interface.

Decorative Images

Decorative images that do not provide important information can be marked as not important for accessibility.

For XML: android:importantForaccessibility="no"

Or for Compose:

Image(
      imageVector = Icons.Filled.AccountCircle,
      contentDescription = null // decorative
    )

Item Labeled with Type or State

One of your views may have a redundant state. Android provides default views with states such as on, off, checked, or unchecked. Adding a state to the readout can result in a confusing experience.

To resolve this accessibility issue, ensure:

  • Checkboxes have an associated label for context
  • State descriptions are not added to the view's description
<TextView
      android:id="@+id/edit_text_label"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:labelFor="@+id/example"
      android:text="Check Label" />

<androidx.appcompat.widget.AppCompatCheckBox
      android:id="@+id/example"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/with_text"/>

Duplicate Item Descriptions

Multiple views within the hierarchy were found to have identical descriptions.

This is not a WCAG failure and there may be cases where this is a requirement. If content descriptions are duplicated, ensure each provides enough context to let the user know what the outcome would be of interacting with the view.

Any link should contain enough text to convey its purpose. When using descriptions like "click here", you must ensure the surrounding text contains enough information to decipher the link's purpose.

Implementation - Clickable Items

Any link should contain enough text to convey its purpose. When using descriptions like "click here", you must ensure the surrounding text contains enough information to decipher the link's purpose.

Duplicate Clickable Views

One of the clickable elements in your view overlaps with another clickable element. You can resolve this accessibility issue in one of the following ways:

  • Moving the clickable elements so they do not collide or overlap.
  • If the views cannot be moved, ensure both views have an appropriately sized tap area and anyone can interact with the elements without issue.

Editable Item Label

Editable fields must have a label describing the purpose of the field.

An example with EditText:

<TextView
      android:id="@+id/edit_text_label"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:labelFor="@+id/edit_text"
      android:text="Enter your username" />

<EditText
      android:id="@+id/edit_text"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:hint="Hint" />

An example with CheckBox:

Utilize a TextView and associate it with the CheckBox element:

val checkBox: CheckBox = ....... // Role: CheckBox
val label: TextView = ....... // Role: Label
label.setLabelFor(checkBox.getId()) // Associate the Checkbox with its Name

Unsupported Item Type

Looks like you may have a custom view. Edit the AccessibilityNodeInfo to provide the className with an appropriate purpose for the view.

val frameLayout = findViewById<FrameLayout>(R.id.custom_view)
frameLayout.setAccessibilityDelegate(object : View.AccessibilityDelegate() {
      override fun onInitializeAccessibilityNodeInfo(
          host: View,
          info: AccessibilityNodeInfo
      ) {
            info.className = "ClassName"
            info.contentDescription = "ContentDescription"
            super.onInitializeAccessibilityNodeInfo(host, info)           
      }
})

Traversal Order

If you can navigate your views using talkback in a way that makes contextual sense, this may be a false positive and doesn't need to be addressed.

If TalkBack does not provide the same information as reading the app without assistive technology, you may consider editing the order of the views. Since it can be tricky to get right and may also include accidentally adding an infinite loop, we advise against editing the traversal order. To alter the traversal order, utilize android:accessibilityTraversalBefore and android:accessibilityTraversalAfter.

Text Scaling

Any text elements should use scalable pixels (sp) over density-independent pixels (dp) to allow the text to scale with the device's font-size accessibility setting.

Touch Target Size

Remediation advice is available under the Touch Target Size Rule for our Android library.

Low Contrast

Remediation advice is available under the Color Contrast Rule for our Android library.