shekhar23/claude-zero-to-hero-android-kmp/android-foldables-adaptive-ui
Claude Code and agent skill by shekhar23/claude-zero-to-hero-android-kmp
- community
Checking that the SKILL.md file is still in the repository.
Adaptive UI and foldable support patterns for Android/Compose - WindowSizeClass for layout decisions, ListDetailPaneScaffold for two-pane layouts, NavigationSuiteScaffold for adaptive navigation, FoldingFeature detection for hinge and table-top postures, and resizable emulator testing. Use this skill whenever building tablet, foldable, or large-screen layouts, or adapting navigation patterns based on available space. Trigger on phrases like "foldable", "tablet layout", "adaptive UI", "WindowSizeClass", "two-pane", "ListDetailPaneScaffold", "NavigationSuiteScaffold", "navigation rail", or "large screen".
Install
npx vskill@latest install shekhar23/claude-zero-to-hero-android-kmp/android-foldables-adaptive-uiSKILL.md
Android Foldables and Adaptive UI
Core Principles
- Never use hardcoded dp breakpoints. Always use
WindowSizeClassfor layout decisions. - Navigation chrome (bottom bar, rail, drawer) should adapt to width, not device type.
- Two-pane layouts should degrade gracefully to single-pane on compact screens.
- Foldable postures (table-top, book mode) are additive — they adjust an existing adaptive layout.
- Test on resizable emulator, not just specific device profiles.
Dependencies
Version catalog entries:
WindowSizeClass
Obtaining the Class
Obtain WindowSizeClass once at the Activity level and propagate it down via CompositionLocal or pass it explicitly:
The Three Widths
WindowWidthSizeClass | Typical screen | Typical layout | |
|---|---|---|---|
Compact | Phone portrait | Single pane, bottom nav | |
Medium | Phone landscape, small tablet, open foldable | Transitional; nav rail | |
Expanded | Tablet, large foldable unfolded | Two-pane, nav drawer |
Make all layout decisions relative to the window size class, not raw dp values.
Adaptive Navigation with NavigationSuiteScaffold
NavigationSuiteScaffold from the Material3 adaptive library automatically switches between bottom bar, navigation rail, and navigation drawer based on WindowAdaptiveInfo:
NavigationSuiteScaffold internally reads WindowAdaptiveInfo from the local composition. Do not override its layout decisions with manual size checks.
Two-Pane Layout with ListDetailPaneScaffold
Use ListDetailPaneScaffold for list-detail navigation patterns:
On Compact screens the scaffold shows one pane at a time with back-stack navigation. On Expanded screens both panes are visible simultaneously. This behavior is handled by the scaffold — do not manually toggle pane visibility with if (isExpanded) checks.
Handling Foldable Postures with FoldingFeature
FoldingFeature describes the physical hinge or fold state. Obtain it from WindowInfoTracker:
Table-Top Mode
Table-top mode is when the fold is horizontal and the device is resting flat:
Book Mode
Book mode is when the fold is vertical and the device is held open like a book:
Hinge Bounds
When content must avoid the hinge, use FoldingFeature.bounds to calculate safe drawing areas. Do not hardcode hinge width values — they vary by device.
Passing WindowSizeClass Through the Nav Graph
Pass windowSizeClass into composables that need it or provide it via CompositionLocal:
Responsive Compose Layout Patterns
Use width-class-aware layout switching:
Avoid mixing BoxWithConstraints pixel comparisons with WindowSizeClass checks for the same decision — pick one source of truth.
Anti-Patterns
- Hardcoding
if (screenWidth > 600.dp)— brittle, ignores system bar insets, and diverges from system semantics. - Creating custom NavigationRail/BottomNavigation visibility logic by hand —
NavigationSuiteScaffoldhandles this correctly. - Calling
calculateWindowSizeClassinside a composable deeper than the Activity root — create it once at the top. - Showing two panes manually with
Row { if (isTablet) DetailPane() }instead ofListDetailPaneScaffold— loses correct back-stack behavior. - Ignoring
Medium— many foldables and landscape phones land here; treat it as a real layout target.
Testing Adaptive UIs
Resizable Emulator
Use the resizable emulator (API 34+) and resize the window to exercise all three WindowSizeClass states without a physical device.
Compose Preview with WindowSizeClass
Robolectric WindowSizeClass Tests
Checklist: Adaptive UI Feature
- [ ] Obtain
WindowSizeClassonce at Activity root - [ ] Never use hardcoded dp breakpoints for layout decisions
- [ ] Use
NavigationSuiteScaffoldfor adaptive nav chrome - [ ] Use
ListDetailPaneScaffoldfor two-pane list/detail flows - [ ] Handle
Mediumas a real target, not a fallback - [ ] Check
FoldingFeaturefor hinge-aware layouts where relevant - [ ] Add multi-size
@Previewannotations for adaptive composables - [ ] Test with resizable emulator across all three width classes
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/android-foldables-adaptive-ui/SKILL.md
Popularity
- Repository stars
- 9
- Repository forks
- 5
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/shekhar23/claude-zero-to-hero-android-kmp/android-foldables-adaptive-ui)