androidx.compose.foundation.lazy
LazyListScope
Interface · from org.jetbrains.compose.foundation:foundation:1.12.2
Inside a LazyColumn or LazyRow, you don't call composables directly. You describe the items, and the list creates them when they scroll into view.
LazyColumn {
item { Header() }
items(contacts, key = { it.id }) { contact -> ContactRow(contact) }
item { Footer() }
}
Besides the members below, there are extension functions for lists and arrays: items(list) { element -> } and itemsIndexed(list) { index, element -> }. Your editor imports them from androidx.compose.foundation.lazy.
interface LazyListScope
Used by
Parameters that take a LazyListScope.
Functions
item
fun item(
key: Any? = null,
contentType: Any? = null,
content: @Composable LazyItemScope.() -> Unit,
)
Adds one item, like a header or a footer.
items
fun items(
count: Int,
key: ((index: Int) -> Any)? = null,
contentType: (index: Int) -> Any? = { null },
itemContent: @Composable LazyItemScope.(index: Int) -> Unit,
)
Adds count items. The content gets the index: items(100) { index -> Text("Row $index") }.
stickyHeader
fun stickyHeader(
key: Any? = null,
contentType: Any? = null,
content: @Composable LazyItemScope.(Int) -> Unit,
)
Adds a header that stays at the top while the items after it scroll, until the next sticky header pushes it away.