piyushverma0/android-agent-skills/adaptive-ui

Claude Code and agent skill by piyushverma0/android-agent-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Adaptive UI for Android — responsive layouts for phones, tablets, foldables, Chromebooks, and large screens. Use this skill for EVERY screen you build. Triggers on: WindowSizeClass, ListDetailPaneScaffold, SupportingPaneScaffold, ThreePaneScaffold, NavigationSuiteScaffold, NavigationRail, NavigationDrawer, adaptive layout, responsive, tablet layout, foldable, FoldingFeature, two-pane, large screen, GridCells.Adaptive, WindowWidthSizeClass, WindowHeightSizeClass, landscape, Chromebook, bottom sheet to side sheet, dialog sizing, content width, LazyVerticalGrid, breakpoints, hinge, fold state. Apply to EVERY screen — AI agents without this produce phone-only apps on 1B+ large-screen Android devices.

Install

npx vskill@latest install piyushverma0/android-agent-skills/adaptive-ui

SKILL.md

The same SKILL.md was published earlier as piyushverma0/android-agent-skills/adaptive-ui.

Adaptive UI — Every Screen, Every Device

Android has 1B+ active large-screen devices. Every screen must work on phones, tablets, foldables, and Chromebooks. These 10 rules make that happen automatically.

The golden rule

Before placing any layout element: ask how it looks at 600dp width AND 840dp width. If the answer is "one stretched column" — it's wrong.

Setup — required dependencies

toml
[versions]
material3Adaptive = "1.1.0"
[libraries]
material3-adaptive = { group = "androidx.compose.material3.adaptive", name = "adaptive", version.ref = "material3Adaptive" }
material3-adaptive-layout = { group = "androidx.compose.material3.adaptive", name = "adaptive-layout", version.ref = "material3Adaptive" }
material3-adaptive-navigation = { group = "androidx.compose.material3.adaptive", name = "adaptive-navigation", version.ref = "material3Adaptive" }
windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class", version.ref = "material3" }

Rule 1: NavigationSuiteScaffold — zero-code adaptive navigation

kotlin
// ✅ One component → BottomBar on phone, Rail on tablet, Drawer on large screen
@Composable
fun MyApp() {
val navController = rememberNavController()
val currentEntry by navController.currentBackStackEntryAsState()
NavigationSuiteScaffold(
navigationSuiteItems = {
TopLevelRoute.entries.forEach { route ->
item(
selected = currentEntry?.destination?.hasRoute(route.routeClass) == true,
onClick = { navController.navigateTopLevel(route) },
icon = {
Icon(
if (currentEntry?.destination?.hasRoute(route.routeClass) == true)
route.selectedIcon else route.icon,
contentDescription = stringResource(route.labelRes)
)
},
label = { Text(stringResource(route.labelRes)) },
badge = if (route.badgeCount > 0) {
{ Badge { Text("${route.badgeCount}") } }
} else null
)
}
}
) {
AppNavHost(navController)
}
}
// Compact (< 600dp): BottomNavigationBar
// Medium (600-840dp): NavigationRail
// Expanded (> 840dp): NavigationDrawer (permanent)
// No extra code needed — ever.
// ✅ Define top-level routes
enum class TopLevelRoute(
val routeClass: KClass<*>,
val icon: ImageVector,
val selectedIcon: ImageVector,
@StringRes val labelRes: Int,
val badgeCount: Int = 0
) {
Home(HomeRoute::class, Icons.Outlined.Home, Icons.Filled.Home, R.string.home),
Search(SearchRoute::class, Icons.Outlined.Search, Icons.Filled.Search, R.string.search),
Inbox(InboxRoute::class, Icons.Outlined.Inbox, Icons.Filled.Inbox, R.string.inbox, badgeCount = 3),
Profile(ProfileRoute::class, Icons.Outlined.Person, Icons.Filled.Person, R.string.profile),
}
// ✅ Top-level navigate helper — prevents duplicate backstack entries
fun NavController.navigateTopLevel(route: TopLevelRoute) {
navigate(route.routeClass.objectInstance ?: return) {
popUpTo(graph.findStartDestination().id) { saveState = true }
launchSingleTop = true
restoreState = true
}
}

Rule 2: ListDetailPaneScaffold — master-detail for all list screens

kotlin
// ✅ Every list+detail screen should use this — replaces simple NavHost navigation
@Composable
fun ItemsScreen() {
val navigator = rememberListDetailPaneScaffoldNavigator<String>()
BackHandler(navigator.canNavigateBack()) {
navigator.navigateBack()
}
ListDetailPaneScaffold(
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
AnimatedPane {
ItemListPane(
onItemSelected = { id ->
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, id)
}
)
}
},
detailPane = {
AnimatedPane {
val itemId = navigator.currentDestination?.content
if (itemId != null) {
ItemDetailPane(itemId = itemId)
} else {
// Large screen placeholder when nothing selected
Box(Modifier.fillMaxSize(), Alignment.Center) {
Text("Select an item", style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant)
}
}
}
}
)
}
// Phone: list screen → tap → detail screen (back button returns to list)
// Tablet: list + detail side by side, selection updates detail pane live

Rule 3: WindowSizeClass breakpoints — 3 layout tiers

kotlin
// ✅ Access WindowSizeClass from composable hierarchy
@Composable
fun MyScreen() {
val windowSizeClass = currentWindowAdaptiveInfo().windowSizeClass
val isCompact = windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.COMPACT // < 600dp
val isMedium = windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.MEDIUM // 600-840dp
val isExpanded = windowSizeClass.windowWidthSizeClass == WindowWidthSizeClass.EXPANDED // > 840dp
when {
isExpanded -> ExpandedLayout() // desktop-like, two or three columns
isMedium -> MediumLayout() // tablet, two columns or wider single
else -> CompactLayout() // phone, single column
}
}
// ✅ Extension helpers (add to AdaptiveTokens.kt)
val WindowSizeClass.isCompact get() = windowWidthSizeClass == WindowWidthSizeClass.COMPACT
val WindowSizeClass.isMedium get() = windowWidthSizeClass == WindowWidthSizeClass.MEDIUM
val WindowSizeClass.isExpanded get() = windowWidthSizeClass == WindowWidthSizeClass.EXPANDED
// ✅ Also check height for landscape phones (compact height)
val WindowSizeClass.isShortLandscape get() =
windowHeightSizeClass == WindowHeightSizeClass.COMPACT && !isCompact

Rule 4: Adaptive Grid — fills screen width automatically

kotlin
// ✅ GridCells.Adaptive — correct column count for any screen width
LazyVerticalGrid(
columns = GridCells.Adaptive(minSize = 180.dp), // as many as fit
contentPadding = PaddingValues(Spacing.md),
horizontalArrangement = Arrangement.spacedBy(Spacing.sm),
verticalArrangement = Arrangement.spacedBy(Spacing.sm)
) {
items(items, key = { it.id }) { item ->
ItemCard(item, modifier = Modifier.fillMaxWidth())
}
}
// Phone (360dp): 1 column. Standard phone (412dp): 2 columns.
// Tablet (768dp): 4 columns. Large screen (1200dp): 6 columns. Zero extra code.
// ✅ Fixed columns per breakpoint when design requires control
@Composable
fun DesignControlledGrid(items: List<Item>, windowSizeClass: WindowSizeClass) {
val columns = when {
windowSizeClass.isExpanded -> GridCells.Fixed(4)
windowSizeClass.isMedium -> GridCells.Fixed(3)
else -> GridCells.Fixed(2)
}
LazyVerticalGrid(columns = columns) { /* ... */ }
}

Rule 5: Foldable support — FoldingFeature states

kotlin
// ✅ Detect and respond to fold states
@Composable
fun FoldAwareScreen() {
val windowInfo = currentWindowAdaptiveInfo()
val posture = windowInfo.windowPosture
val hinges = posture.hingeList
val foldingFeature = hinges.firstOrNull()
when {
foldingFeature?.state == FoldingFeature.State.HALF_OPENED &&
foldingFeature.orientation == FoldingFeature.Orientation.HORIZONTAL -> {
// Tabletop / book posture — split top/bottom
TabletopLayout()
}
foldingFeature?.state == FoldingFeature.State.FLAT -> {
// Fully unfolded — treat as large tablet
ExpandedLayout()
}
else -> {
// Phone / folded state
CompactLayout()
}
}
}
// ✅ Tabletop layout — content above, controls below the hinge
@Composable
fun TabletopLayout() {
Column(Modifier.fillMaxSize()) {
// Content above hinge
Box(Modifier.weight(1f).fillMaxWidth()) {
VideoPlayer() // or map, camera, media player
}
// Controls below hinge — easy thumb reach
Box(Modifier.weight(0.4f).fillMaxWidth()
.background(MaterialTheme.colorScheme.surfaceContainerLow)) {
PlaybackControls()
}
}
}

Rule 6: Content width constraints — never stretch text on large screens

kotlin
// ✅ Cap readable content width — typography research: 75 chars max per line
@Composable
fun ReadableContent(content: @Composable ColumnScope.() -> Unit) {
BoxWithConstraints(Modifier.fillMaxSize()) {
val maxContentWidth = minOf(maxWidth, 720.dp) // never wider than 720dp
Box(Modifier.fillMaxSize(), Alignment.TopCenter) {
Column(
Modifier.width(maxContentWidth)
.padding(horizontal = Spacing.md)
.verticalScroll(rememberScrollState()),
content = content
)
}
}
}
// ✅ Adaptive horizontal padding
@Composable
fun WindowSizeClass.contentPadding() = PaddingValues(
horizontal = when {
isExpanded -> Spacing.xl // 32dp on large screen
isMedium -> Spacing.lg // 24dp on tablet
else -> Spacing.md // 16dp on phone
}
)

Rule 7: Bottom sheet → side sheet on tablets

kotlin
// ✅ Adapt sheet direction to screen width
@Composable
fun AdaptiveSheet(
isVisible: Boolean,
onDismiss: () -> Unit,
windowSizeClass: WindowSizeClass = currentWindowAdaptiveInfo().windowSizeClass,
content: @Composable () -> Unit
) {
if (windowSizeClass.isCompact) {
// Phone: bottom sheet
if (isVisible) {
ModalBottomSheet(onDismissRequest = onDismiss) {
Box(Modifier.navigationBarsPadding()) { content() }
}
}
} else {
// Tablet/desktop: side sheet from end edge
AnimatedVisibility(
visible = isVisible,
enter = slideInHorizontally(initialOffsetX = { it }),
exit = slideOutHorizontally(targetOffsetX = { it })
) {
Box(
Modifier.fillMaxHeight().width(360.dp)
.background(MaterialTheme.colorScheme.surfaceContainerLow)
.align(Alignment.CenterEnd)
) {
Column {
Row(Modifier.fillMaxWidth().padding(Spacing.md),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically) {
Text("Filter", style = MaterialTheme.typography.titleMedium)
IconButton(onDismiss) { Icon(Icons.Default.Close, "Close") }
}
content()
}
}
}
}
}

Rule 8: Adaptive dialog — constrained on large screens

kotlin
// ✅ Alert dialogs — constrain width on tablets
@Composable
fun AppDialog(
title: String, body: String, onConfirm: () -> Unit, onDismiss: () -> Unit,
confirmText: String = "Confirm", dismissText: String = "Cancel"
) {
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(title) },
text = { Text(body, style = MaterialTheme.typography.bodyMedium) },
modifier = Modifier.widthIn(max = 400.dp), // never full-width on tablet
confirmButton = { TextButton(onConfirm) { Text(confirmText) } },
dismissButton = { TextButton(onDismiss) { Text(dismissText) } }
)
}

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
15
7-day trend score
14

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/piyushverma0/android-agent-skills/adaptive-ui/badge)](https://verified-skill.com/skills/piyushverma0/android-agent-skills/adaptive-ui)

Something wrong with this skill or its page? Tell us.