The horizontally scrolling list that only composes and lays out the currently visible items.
LazyRowSample
@Sampled
@Composable
fun LazyRowSample() {
val itemsList = (0..5).toList()
val itemsIndexedList = listOf("A", "B", "C")
LazyRow {
items(itemsList) { Text("Item is $it") }
item { Text("Single item") }
itemsIndexed(itemsIndexedList) { index, item -> Text("Item at index $index is $item") }
}
}
LazyListCacheWindowSample
@Sampled
@Composable
fun LazyListCacheWindowSample() {
val itemsList = (0..100).toList()
LazyColumn(cacheWindow = LazyLayoutCacheWindow(aheadFraction = 0.5f, behindFraction = 0.2f)) {
items(itemsList) { item -> Text("Item $item") }
}
}