ikn*_*now 15 android kotlin android-jetpack-compose android-jetpack-compose-list
有没有办法以编程方式滚动LazyColumn到列表中的某个项目?我认为可以通过提升LazyColumn参数来完成,state: LazyListState = rememberLazyListState()但我不知道如何更改此状态,例如单击按钮。
Gab*_*tti 12
通过1.0.x LazyListState支持滚动位置
scrollToItem()“立即”捕捉滚动位置的函数,animateScrollToItem() 使用动画滚动就像是:
val listState = rememberLazyListState()
// Remember a CoroutineScope to be able to launch
val coroutineScope = rememberCoroutineScope()
LazyColumn(state = listState) {
// ...
}
Button (
onClick = {
coroutineScope.launch {
// Animate scroll to the 10th item
listState.animateScrollToItem(index = 10)
}
}
){
Text("Click")
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4977 次 |
| 最近记录: |