Control Scrolling in Jetpack Compose

PHOTO EMBED

Sun Jun 20 2021 19:49:37 GMT+0000 (Coordinated Universal Time)

Saved by @swalia #lazycolumn #list #jetpackcompose

Row {
    Button(onClick = {
        coroutineScope.launch {
            // 0 is the first item index
            scrollState.animateScrollToItem(0)
        }
    }) {
        Text("Scroll to the top")
    }

    Button(onClick = {
        coroutineScope.launch {
            // listSize - 1 is the last index of the list
            scrollState.animateScrollToItem(listSize - 1)
        }
    }) {
        Text("Scroll to the end")
    }
}
content_copyCOPY

https://developer.android.com/courses/pathways/compose