Skip to content
tezvyn:

How do you display a large list efficiently in Jetpack Compose?

Source: developer.android.comMediumHow cards are made

How do you display a large list efficiently in Jetpack Compose?

This tests understanding of Compose lazy versus eager layout. A strong answer names LazyColumn or LazyRow, notes visible-only composition, and contrasts Column which lays out everything upfront.

What's really being asked

Whether the candidate understands the difference between eager and lazy composition in Jetpack Compose, specifically how viewport recycling prevents linear composition and memory costs in large lists. Interviewers want to see that you know when to reach for LazyColumn or LazyRow instead of a standard Column, and that you understand the underlying measurement and layout behavior.

The full answer

First, name the correct composables which are LazyColumn for vertical lists and LazyRow for horizontal lists. Second, explain the core mechanism which is that lazy containers only compose items currently in or near the viewport using a recycled item pool, while a Column with a loop composes every child eagerly during the composition phase. Third, mention that lazy lists perform lazy measurement and layout so offscreen items do not participate in layout passes, whereas Column measures all children even if they are scrolled away. Fourth, note the importance of providing stable keys via the key parameter in items blocks so Compose can identify individual items across recompositions and enable efficient recycling. Fifth, briefly mention that lazy lists offer built-in semantics and scrolling logic that Column lacks.

The mistakes people make

Suggesting Column with a for loop and claiming it is fine for a few hundred items without acknowledging the composition cliff. Saying RecyclerView is the only answer and ignoring Compose native lazy lists. Confusing LazyColumn with Column and stating both recycle views, which is false because Column is a simple layout that holds all composables in memory. Forgetting to mention keys and implying that lazy lists magically handle all performance issues without proper item identity.

What usually comes next

How would you handle varying item heights or widths in a lazy list. What is the role of rememberLazyListState and how would you implement scroll position restoration. How do you optimize recompositions inside lazy list items using stable classes or immutable data. When would you choose LazyVerticalGrid over LazyColumn. How does paging or windowed loading integrate with a lazy list.

A concrete example

Imagine displaying a chat history with ten thousand messages. Using Column would force Compose to instantiate ten thousand MessageCard composables, allocate corresponding Modifier chains, and retain them in memory even when scrolled offscreen, leading to jank on first render and out of memory crashes. Using LazyColumn with items indexed by messageId as keys composes only the fifteen or twenty messages visible on a modern phone screen plus a small buffer, reusing the same composition slots as the user scrolls, keeping memory flat and frame times under sixteen milliseconds.

Interview question

What fundamentally distinguishes LazyColumn from a standard Column when displaying thousands of items in Jetpack Compose?

  • a.Column recycles offscreen composables similarly to LazyColumn, but it lacks built-in scrolling support
  • b.LazyColumn automatically generates stable keys for every item, preventing recomposition without developer intervention
  • c.LazyColumn only composes and measures items visible in or near the viewport, recycling slots during scroll, while Column eagerly composes every childCorrect
  • d.LazyColumn defers measurement until scroll but retains all composables in memory to avoid reallocation overhead
Why?

LazyColumn only composes visible items and recycles their slots, keeping memory flat and frame times low, whereas Column eagerly instantiates every child upfront. Option A is tempting but wrong because Column does not recycle views—it holds all composables in memory regardless of scroll position.

Just read this? Test yourself on what you have been reading.

Read the original → developer.android.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on android — each one lists the topics its interview covers.

See open roles