LazyRow para Carrosséis
Crie uma prateleira com rolagem horizontal.
LazyRow para Carrosséis é uma aula grátis de Jetpack Compose Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Jetpack Compose Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Jetpack Compose Academy inclui 4 aulas no total.
Partes desta aula ainda não foram traduzidas e aparecem em inglês.
Scrolling Sideways
Sometimes content should slide left and right, like a movie shelf. For that you use LazyRow, the horizontal cousin of LazyColumn. ↔️
Why Not a Plain Row?
A plain Row composes every child immediately and cannot scroll. A LazyRow scrolls horizontally and only builds the items in view.
Basic LazyRow
You feed LazyRow items just like a column, but they line up side by side instead of stacking.
LazyRow {
items(movies) { movie ->
MovieCard(movie)
}
}Spacing Cards Apart
Carousel cards need gaps. Use horizontalArrangement with spacedBy to set a consistent space between each card.
LazyRow(
horizontalArrangement = Arrangement.spacedBy(12.dp)
) { }Padding at the Ends
Add contentPadding so the first card peeks in from the edge instead of being clipped flush against it.
contentPadding = PaddingValues(horizontal = 16.dp)Sizing Each Card
Give each carousel item a fixed width so cards stay uniform as the user swipes through them.
MovieCard(movie, Modifier.width(140.dp))A Peek of the Next Card
Make a fraction of the next card visible to hint there is more. A slightly smaller card width relative to the screen does this nicely.
val cardWidth = screenWidth * 0.8f
MovieCard(movie, Modifier.width(cardWidth))Headers Above Carousels
A carousel usually sits under a title. Compose the LazyRow inside a Column, with a Text header above it.
Column {
Text("Trending Now")
LazyRow { items(movies) { MovieCard(it) } }
}Nesting in a LazyColumn
A home screen often stacks many carousels. Place several LazyRow rows inside a parent LazyColumn for a Netflix-style feed.
LazyColumn {
items(shelves) { shelf ->
Shelf(shelf)
}
}Each Row Needs Width
A LazyRow inside a LazyColumn fills the available width automatically. Just ensure the parent gives it a finite width to measure against.
When to Use LazyRow
Reach for LazyRow for shelves, chip filters, story bubbles, and any content that invites a horizontal swipe rather than a downward scroll.
Quick Check
Think about horizontal scrolling.
Recap: Carousels
You built horizontal shelves with LazyRow: side-by-side items, spacing, end padding, fixed-width cards, and nesting inside a feed. 🎬
Aprenda Kotlin com um tutor de IA — grátis
Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.
- Cursos
- 30
- Aulas
- 120
Perguntas Frequentes
A aula “LazyRow para Carrosséis” é grátis?
Sim — o texto completo de “LazyRow para Carrosséis” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Jetpack Compose Academy, atualize para CoddyKit PRO. O curso de Jetpack Compose Academy inclui 4 aulas no total.
O que vou aprender em “LazyRow para Carrosséis”?
Crie uma prateleira com rolagem horizontal. Você pratica Jetpack Compose Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.
Preciso ter experiência prévia para começar Jetpack Compose Academy?
Nenhuma experiência prévia é necessária. Jetpack Compose Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.
Quanto tempo leva a aula “LazyRow para Carrosséis”?
A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.
Posso escrever e executar código nesta aula de Jetpack Compose Academy?
Sim. Cada aula de Jetpack Compose Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.
Todas as aulas deste curso
- Galerias com LazyVerticalGrid
- LazyRow para Carrosséis
- Células de Grade Adaptáveis e Fixas
- Estado de Rolagem e Rolagem Programática