Expert: features and shipping · Permissions, Material 3 and polish · topic 38 of 50 · 30 min
Accessibility and adaptive layouts
Explanation
Why accessibility matters
Millions of people in India live with a visual, hearing or motor disability, and many more are elderly users with weaker eyesight. Android has built-in tools for them: TalkBack reads the screen aloud, font scaling enlarges text, and Switch Access lets people use the phone with buttons. If your app ignores these, those users simply cannot use it. Accessibility also helps everyone: big tap targets and clear contrast are easier for anyone using a phone in bright sunlight or on a moving bus.
Checklist for every screen
| Rule | How in Compose |
|---|---|
| Describe meaningful images and icons | contentDescription = "Add to cart"; null for decorative ones |
| Touch targets at least 48 x 48 dp | Material components do this; for custom clickables use Modifier.minimumInteractiveComponentSize() or size(48.dp) |
| Enough colour contrast | Use theme on-colours; aim for at least 4.5:1 for normal text |
| Text that can grow | Use sp and avoid fixed heights that cut off large text |
| Do not rely on colour alone | Add text or icons, for example "Failed" next to a red mark |
Semantics
Compose builds a semantics tree alongside the UI: a description of what each element means, which TalkBack and UI tests read. Most components fill it in automatically. You can merge a group into one announcement or add meaning to custom elements with Modifier.semantics.
Row(
Modifier
.clickable(onClick = onOpen)
.semantics(mergeDescendants = true) { } // read the row as one item
.padding(16.dp)
) {
Icon(Icons.Default.Star, contentDescription = null) // decorative
Text("4.5 rating")
Text("Annapurna Mess, 1.2 km")
}Testing it yourself
- Turn on TalkBack in Settings > Accessibility and try to complete your main task with your eyes closed.
- Set font size and display size to the largest values and check nothing is cut off.
- Use Accessibility Scanner (a free Google app) to find small targets and low contrast.
- Check the Play Console pre-launch report, which flags common accessibility issues.
Adaptive layouts
Android runs on phones, foldables, tablets and Chromebooks. Stretching a phone layout across a tablet wastes space. Window size classes group window widths into Compact (most phones in portrait), Medium (small tablets, unfolded foldables) and Expanded (large tablets, desktop). Your layout chooses a structure per class.
@Composable
fun MailApp(windowSizeClass: WindowSizeClass) {
when (windowSizeClass.windowWidthSizeClass) {
WindowWidthSizeClass.COMPACT -> SingleColumnInbox() // list, then details on a new screen
else -> Row { InboxList(Modifier.weight(1f)); MessagePane(Modifier.weight(2f)) } // list + details side by side
}
}Material 3 also offers adaptive components such as NavigationSuiteScaffold, which shows a bottom bar on phones and a navigation rail on wider screens automatically.
Common mistakes
- Tiny custom icons as buttons (24 dp) with no padding: hard to tap.
- Text in fixed-height boxes that gets cut off at large font sizes.
- Status shown only by colour (green/red dot).
- Designing only for one phone size and never testing in landscape or on a tablet emulator.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
Accessibility and adaptive layouts · 1/6
Accessible apps work for everyone, including screen reader users and people who use large fonts.
Prefer a video by a teacher? Find free videos on “jetpack compose accessibility talkback semantics window size class” on YouTube ↗
In real life: A bank app that elderly users can use
A bank's app is used by many senior citizens. The team tests every release with the largest font size and with TalkBack, gives every icon a clear description ("Show balance", "Scan QR"), keeps buttons large, and labels transaction status with words ("Successful", "Failed") as well as colour. On tablets, the account list and transaction details appear side by side.
IconButton(onClick = onToggleBalance) {
Icon(
imageVector = if (hidden) Icons.Default.Visibility else Icons.Default.VisibilityOff,
contentDescription = if (hidden) "Show balance" else "Hide balance",
)
}Practice (0/3 done)
What is the recommended minimum touch target size on Android?
A payment status is shown only as a green or red dot. What is the accessibility problem?
Audit one of your apps: turn on TalkBack and complete the main task with eyes closed, set the largest font size, and run Accessibility Scanner. Fix at least three problems (descriptions, target sizes, cut-off text, colour-only status). Then add a two-pane layout for Expanded width.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Material 3 themingPermissions, Material 3 and polish · same module
- Runtime permissionsPermissions, Material 3 and polish · same module
- Responsive and adaptive designFlutter and Dart · Responsive design and testing
- Accessibility basicsFrontend Web Development · Forms, semantic HTML and accessibility
- Accessibility in depth: keyboard, ARIA and WCAGFrontend Web Development · Fast, accessible, findable and safe: quality for real sites
- Images, icons, fonts and themesFlutter and Dart · Layouts
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
What is TalkBack?
Answer: Android's built-in screen reader
It reads the screen aloud.
What does mergeDescendants = true in semantics do?
Answer: Lets TalkBack read a group as one item
Grouping reduces the number of stops.
Which window width class do most phones in portrait have?
Answer: Compact
Phones in portrait are Compact.
Which tool from Google scans an app for accessibility problems on the device?
Answer: Accessibility Scanner
Accessibility Scanner suggests fixes.
What is the difference between responsive and adaptive?Related
Answer: Responsive fits the space; adaptive also fits platform conventions and input
Both matter on multi-platform apps.
What does dp stand for and why use it?Related
Answer: Density-independent pixels; sizes look similar on all screens
dp scales with screen density.
What is a screen reader?Related
Answer: Software that reads the page aloud
Screen readers turn the page into speech (or braille) for blind and low-vision users.
From Accessibility basics
What contrast ratio does WCAG AA need for normal-size body text?Related
Answer: 4.5:1
Normal text needs at least 4.5:1. Large text and parts of controls need at least 3:1.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- This is the last topic of “Permissions, Material 3 and polish”. The module exam comes next.
- Module 9 exam: Permissions, Material 3 and polish · 13 questions · 25 min, without help. 4 topics of this module still to finish first.
- Then the next module, Testing Android apps. 50 topics left in the course before the final exam.