Adaptive Layouts, Dark Mode and Accessibility

Android Development 12 min min read Updated: Nov 16, 2026 Intermediate
Adaptive Layouts, Dark Mode and Accessibility
Intermediate Topic 9 of 9

Edge-to-Edge and Insets

Modern Android apps draw behind the status and navigation bars. You handle that with insets. Scaffold does most of the work through innerPadding.

kotlin override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() // draw behind system bars setContent { App() } } Column(Modifier.fillMaxSize().safeDrawingPadding()) { /* content stays clear of bars and cutouts */ }

Window Size Classes

ClassTypical deviceLayout idea
Compact widthPhone in portraitOne column, bottom navigation
Medium widthFoldable, small tabletNavigation rail, two panes when it fits
Expanded widthTablet, desktop windowList and detail side by side
kotlin @Composable fun AdaptiveHome() { val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass if (windowSizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_EXPANDED_LOWER_BOUND)) { Row { ListPane(Modifier.weight(1f)) DetailPane(Modifier.weight(2f)) } } else { ListPane(Modifier.fillMaxSize()) } }
Why this matters: Google expects apps to work well on tablets, foldables and resizable windows. Apps that fail there can get lower quality ratings. Test with the Resizable emulator.

Dark Theme

kotlin val dark = isSystemInDarkTheme() // Use MaterialTheme.colorScheme everywhere, never hard-coded white or black Surface(color = MaterialTheme.colorScheme.background) { /* ... */ } @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES, name = "Dark") @Preview(fontScale = 1.5f, name = "Large font") @Composable fun ScreenPreview() { HelloAppTheme { HomeScreen() } }

Accessibility

kotlin IconButton(onClick = onFavorite) { Icon(Icons.Default.Favorite, contentDescription = "Add to favorites") } Row(Modifier.semantics(mergeDescendants = true) { }) { // read as one item Text("Total"); Text("$20") } Text("Heading", Modifier.semantics { heading() }) Box(Modifier.clearAndSetSemantics { }) // hide decorative content
CheckHow
TalkBackTurn on in Settings > Accessibility and use your app with eyes closed
Font sizeSettings > Display > Font size, and the preview fontScale
ContrastText must stand out from its background
Touch targetsAt least 48 x 48 dp
Accessibility ScannerFree Google app that suggests fixes
Tip: Use Modifier.minimumInteractiveComponentSize() for custom clickable elements, and never rely on color alone to show meaning.

Conclusion

Adaptive apps use insets, size classes and theme colors. Accessible apps have descriptions, good contrast and large enough touch targets.

Quick Summary: Use edge-to-edge insets, WindowSizeClass for layouts, theme colors for dark mode and contentDescription and semantics for TalkBack.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators