← ClaudeAtlas

compose-adaptive-layoutslisted

Adaptive Compose layouts per Google's docs: window size classes, list-detail and supporting panes, NavigationSuiteScaffold, state across resizing. Use when UI must work on tablets, foldables, desktop windows, or rotation, and when layouts stretch on large screens, code checks isTablet or locks orientation, or state is lost on resize or fold.
pablitoarango/android-skills · ★ 3 · Web & Frontend · score 74
Install: claude install-skill pablitoarango/android-skills
# Compose Adaptive Layouts Sources of truth: [Adaptive apps](https://developer.android.com/develop/ui/compose/layouts/adaptive), [Build adaptive navigation](https://developer.android.com/develop/ui/compose/layouts/adaptive/build-adaptive-navigation), [Canonical layouts](https://developer.android.com/develop/adaptive-apps/guides/canonical-layouts). ## 1. Adapt to the window, not the device - Decide layout from the **app window size**, which changes with multi-window, desktop windowing, folding and rotation. - Do not check device type (`isTablet`), physical screen size, or orientation, and do not lock orientation. - Keep one adaptive code path instead of separate phone and tablet screens. ```kotlin val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass val isExpanded = windowSizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_EXPANDED_LOWER_BOUND) val isMediumOrLarger = windowSizeClass.isWidthAtLeastBreakpoint(WindowSizeClass.WIDTH_DP_MEDIUM_LOWER_BOUND) ``` | Width class | Typical window | Typical layout | |---|---|---| | Compact | Phone portrait | Single pane, navigation bar | | Medium | Phone landscape, small tablet, unfolded foldable | Single pane or two panes, navigation rail | | Expanded and larger | Tablet landscape, desktop window | Two or more panes, navigation rail or drawer | - Read the size class once near the top (the app or screen root), and pass layout decisions down as parameters or through a UI state holder (`compose-ui`). - Width driv