Skip to content
Commitwise
Menu

How do you make a Jetpack Compose screen accessible?

AndroidMid-level

In shortGive meaningful icons and images content descriptions and decorative ones null, merge related content into single TalkBack stops, give custom controls roles and states with toggleable or selectable, mark headings, expose secondary actions as custom actions, keep 48 dp touch targets, let layouts grow with 200% fonts, check contrast, and test it.

Model answer

Semantics: Compose builds a semantics tree that TalkBack, Switch Access and tests use.

  • contentDescription describes meaningful non-text content (“Add to favorites”); decorative images use null.
  • Merge related content: clickable and semantics(mergeDescendants = true) make a card one stop that reads title and details together.
  • Roles and states: use IconToggleButton, Checkbox, Switch, or Modifier.toggleable/selectable with a Role, so TalkBack announces “switch, on”. Custom states use stateDescription.
  • Structure: heading() on section titles, traversalIndex/isTraversalGroup when reading order differs from layout.
  • Custom actions for secondary actions and gestures like swipe-to-delete.
  • Touch targets of at least 48 dp (Material components handle it).

Visual: text in sp, no fixed heights around text (heightIn(min = …)), layouts that switch to vertical at large font scales (up to 200%, nonlinear since Android 14), contrast of at least 4.5:1 for body text, and never color alone for meaning (errors with isError, supporting text and error semantics).

Testing: Compose UI tests that find nodes by content description and assert roles and states, accessibility checks in Espresso and Compose tests, @PreviewFontScale and screenshot tests, plus manual TalkBack and Accessibility Scanner passes.

What they're looking for

Semantics basics, merging, roles and states, headings and traversal, custom actions, touch targets, font scaling and contrast, and automated plus manual testing.

Common mistakes

  • contentDescription on every image, including decorative ones.
  • Custom controls built with clickable only.
  • Fixed heights that clip large text.

More android questions

Esc

Type to search the whole site.