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?
Asked
Active
Viewed 1,041 times
3

Vadim Kotov
- 8,084
- 8
- 48
- 62

powerman23rus
- 1,297
- 1
- 9
- 17
-
2`LazyColumnForIndexed()` might help. See [this Medium post](https://medium.com/@DamianPetla/list-pagination-with-jetpack-compose-6c25da053858). – CommonsWare Sep 06 '20 at 19:27
1 Answers
3
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.

Ryan M
- 18,333
- 31
- 67
- 74