Lists with LazyColumn
Display scrolling lists efficiently.
Lists with LazyColumn is a free Android Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Android Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Why Not Just a Column?
A Column composes all its children at once. For a long or scrolling list, that wastes memory and slows the UI. You need a list that only builds visible items.
Enter LazyColumn
LazyColumn is a scrollable, vertical list that only composes the items currently on screen — like the old RecyclerView, but far simpler.
LazyColumn {
items(messages) { msg ->
Text(text = msg)
}
}The items() Function
Inside the LazyColumn lambda you call items(list) and give it a composable for each element. Compose calls it lazily as the user scrolls.
LazyColumn {
items(users) { user ->
Text(text = user.name)
}
}Not a Normal Loop
Do not use a regular for loop inside LazyColumn — that defeats laziness. Always use items() (or itemsIndexed()) so Compose can build items on demand.
A Single Header Item
Use item { } (singular) to add one fixed element, like a header, before the looped items.
LazyColumn {
item { Text("Header") }
items(data) { Text(it) }
}itemsIndexed
When you need the position, use itemsIndexed to get both the index and the element.
LazyColumn {
itemsIndexed(data) { index, value ->
Text(text = "$index: $value")
}
}Keys for Stability
Provide a stable key for each item so Compose can track items correctly when the list changes — improving performance and animations.
items(users, key = { it.id }) { user ->
Text(user.name)
}Spacing Items
LazyColumn accepts verticalArrangement and contentPadding to space items and pad the edges of the list.
LazyColumn(
verticalArrangement = Arrangement.spacedBy(8.dp),
contentPadding = PaddingValues(16.dp)
) {
items(data) { Text(it) }
}LazyRow
There is also LazyRow for horizontal scrolling lists — same API, different direction. Great for carousels of cards.
LazyRow {
items(images) { img ->
Image(painter = img, contentDescription = null)
}
}Built-in Scrolling
You do not add a scroll modifier to a LazyColumn — it scrolls automatically. Adding verticalScroll would conflict and crash. Lazy lists handle scrolling themselves.
Putting It Together
A list of items with a header, keys, and spacing.
@Composable
fun MessageList(messages: List<Message>) {
LazyColumn(
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
item { Text("Inbox") }
items(messages, key = { it.id }) { msg ->
Text(text = msg.text)
}
}
}Quick Check
What is the main advantage of LazyColumn over a scrollable Column?
Recap
LazyColumn:
- Builds only visible items — efficient for long lists.
- Use
items()/itemsIndexed(), not aforloop. - Add a
keyfor stability; useitem { }for headers. - It scrolls automatically — no scroll modifier.
LazyRowis the horizontal version.
Frequently asked questions
Is the “Lists with LazyColumn” lesson free?
Yes — the full text of “Lists with LazyColumn” is free to read here on the web, and the Android Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Android Academy course, upgrade to CoddyKit PRO.
What will I learn in “Lists with LazyColumn”?
Display scrolling lists efficiently. You practise Android Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Android Academy?
No prior experience is required. Android Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Lists with LazyColumn” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Android Academy lesson?
Yes. Every Android Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Column, Row, and Box
- The Modifier System
- Alignment and Arrangement
- Lists with LazyColumn