Reputation: 1583
Jetpack compose released with alpha version and I want to implement paging for the LazyColumnFor
compose function. But I can't understand how we can do this because I can't find something to determine scroll position or something similar. Do we have this opportunity right now or this mechanism will be add in the future?
Upvotes: 3
Views: 1175
Reputation: 20207
There is, as of the initial alpha release, not currently a way to detect scroll position. It will be added later, though, with an API something like:
Column {
val state = rememberLazyListState()
Text("First item: ${state.firstVisibleItemIndex}")
LazyColumnFor(
(0..100).toList(),
Modifier.fillMaxWidth(),
state = state
) {
Text("$it", style = currentTextStyle().copy(fontSize = 40.sp))
}
}
This will (once that is merged) display the first visible scroll position in the list.
Upvotes: 3