LazyGridScope
Interface
Common
@LazyGridScopeMarker
sealed interface LazyGridScope
Receiver scope which is used by LazyVerticalGrid
.
Functions
fun item(
key: Any? = null,
span: (LazyGridItemSpanScope.() -> GridItemSpan)? = null,
contentType: Any? = null,
content: @Composable LazyGridItemScope.() -> Unit,
)
Adds a single item to the scope.
Parameters
key | a stable and unique key representing the item. Using the same key for multiple items in the grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. This can be overridden by calling LazyGridState.requestScrollToItem . |
span | the span of the item. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance |
contentType | the type of the content of this item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible. |
content | the content of the item |
fun items(
count: Int,
key: ((index: Int) -> Any)? = null,
span: (LazyGridItemSpanScope.(index: Int) -> GridItemSpan)? = null,
contentType: (index: Int) -> Any? = { null },
itemContent: @Composable LazyGridItemScope.(index: Int) -> Unit,
)
Adds a count
of items.
Parameters
count | the items count |
key | a factory of stable and unique keys representing the item. Using the same key for multiple items in the grid is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the grid will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.This can be overridden by calling LazyGridState.requestScrollToItem . |
span | define custom spans for the items. Default is 1x1. It is good practice to leave it null when this matches the intended behavior, as providing a custom implementation impacts performance |
contentType | a factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible. |
itemContent | the content displayed by a single item |
fun stickyHeader(
key: Any? = null,
contentType: Any? = null,
content: @Composable LazyGridItemScope.(Int) -> Unit,
)
Adds a sticky header item, which will remain pinned even when scrolling after it. The header
will remain pinned until the next header will take its place. Sticky Headers are full span
items, that is, they will occupy LazyGridItemSpanScope.maxLineSpan
.
Parameters
key | a stable and unique key representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one. This can be overridden by calling 'requestScrollToItem' on the 'LazyGridState'. |
contentType | the type of the content of this item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible. |
content | the content of the header. The header index is provided, this is the item position within the total set of items in this lazy list (the global index). |