← ClaudeAtlas

compose-listslisted

Lazy lists, grids and pagers per Google's docs: keys, contentType, item animations, Paging, scroll state, list pitfalls. Use for scrolling lists, grids, carousels, pagers, or RecyclerView and ViewPager replacements, and when items jump or swap state, scroll position resets, or nested scrolling crashes with infinity maximum height constraints.
pablitoarango/android-skills · ★ 3 · AI & Automation · score 74
Install: claude install-skill pablitoarango/android-skills
# Compose Lists, Grids and Pagers Sources of truth: [Lists and grids](https://developer.android.com/develop/ui/compose/lists), [Pager](https://developer.android.com/develop/ui/compose/layouts/pager), [Performance best practices](https://developer.android.com/develop/ui/compose/performance/bestpractices). ## 1. Pick the container | Content | Composable | |---|---| | Vertical / horizontal list | `LazyColumn` / `LazyRow` | | Uniform grid | `LazyVerticalGrid` / `LazyHorizontalGrid` with `GridCells.Fixed(n)` or `GridCells.Adaptive(minSize)` | | Items of different sizes | `LazyVerticalStaggeredGrid` / `LazyHorizontalStaggeredGrid` | | One full page at a time | `HorizontalPager` / `VerticalPager` (Compose Foundation) | | A few items that always fit | `Column` / `Row`, with `verticalScroll` / `horizontalScroll` if needed | Lazy containers compose only visible items; use them for anything that can grow. ## 2. Items Always pass a **stable, unique `key`**, and a `contentType` when the list mixes item kinds. ```kotlin LazyColumn( contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp), verticalArrangement = Arrangement.spacedBy(8.dp), ) { item(key = "header", contentType = "header") { FeedHeader() } items( items = feedItems, key = { it.id }, contentType = { it.type }, ) { item -> FeedItemRow(item = item, onClick = { onItemClick(item.id) }, modifier = Modifier.animateItem()) } } ``` - **Keys** keep item state (inc