LazyRow helps you show a list of items side by side that you can scroll horizontally. It only creates items you see on screen, so it saves memory and runs smoothly.
0
0
LazyRow for horizontal lists in Android Kotlin
Introduction
Showing a list of photos you can swipe left or right.
Displaying categories in a shopping app horizontally.
Showing a row of buttons or tags that scroll sideways.
Displaying a timeline or steps horizontally.
Showing a list of products in a horizontal carousel.
Syntax
Android Kotlin
LazyRow(
modifier = Modifier.fillMaxWidth(),
contentPadding = PaddingValues(horizontal = 16.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
items(yourList) { item ->
Text(text = item)
}
}LazyRow is a composable that shows items horizontally and loads only visible items.
You use items() inside LazyRow to provide the list data and how each item looks.
Examples
Simple LazyRow showing three fruits horizontally.
Android Kotlin
LazyRow {
items(listOf("Apple", "Banana", "Cherry")) { fruit ->
Text(text = fruit)
}
}LazyRow with an empty list shows nothing but still works without errors.
Android Kotlin
LazyRow(
horizontalArrangement = Arrangement.spacedBy(12.dp)
) {
items(emptyList<String>()) { item ->
Text(text = item)
}
}LazyRow with only one item shows that single item horizontally.
Android Kotlin
LazyRow {
items(listOf("One")) { item ->
Text(text = item)
}
}LazyRow showing items at the start, middle, and end horizontally.
Android Kotlin
LazyRow {
items(listOf("Start", "Middle", "End")) { item ->
Text(text = item)
}
}Sample App
This app shows a horizontal list of fruit names you can scroll left or right. The fruits are spaced nicely with padding on the sides.
Android Kotlin
import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.lazy.LazyRow import androidx.compose.foundation.lazy.items import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { MaterialTheme { Surface(modifier = Modifier.fillMaxWidth()) { FruitLazyRow() } } } } } @Composable fun FruitLazyRow() { val fruits = listOf("Apple", "Banana", "Cherry", "Date", "Elderberry") LazyRow( modifier = Modifier.fillMaxWidth(), contentPadding = PaddingValues(horizontal = 16.dp), horizontalArrangement = Arrangement.spacedBy(12.dp) ) { items(fruits) { fruit -> Text(text = fruit) } } }
OutputSuccess
Important Notes
LazyRow only creates items visible on screen, so it uses less memory than a regular Row with many items.
Use contentPadding to add space at the start and end of the list.
Common mistake: Forgetting to use items() inside LazyRow causes errors.
Summary
LazyRow shows horizontal lists efficiently by loading only visible items.
Use items() to provide the list and how each item looks.
It is perfect for scrollable horizontal menus, photos, or tags.