Jetpack Compose 中的过度滚动处理

Ahm*_*out 5 android android-jetpack-compose

我正在尝试在我的应用程序中创建一个下拉刷新逻辑。

我知道它从处理 Overscrolling 开始,但我似乎无法在 compose 中找到与 Overscrolling 有关的任何内容。

它还没有在 Compose 中实现吗?还是隐藏在某处?

我现在正在使用 LazyColumn,但在 LazyListState 中没有找到任何内容。

Dun*_*Luk 7

您可以使用 Google伴奏库中包含的“滑动刷新”功能。

用法示例:

val viewModel: MyViewModel = viewModel()
val isRefreshing by viewModel.isRefreshing.collectAsState()

SwipeRefresh(
    state = rememberSwipeRefreshState(isRefreshing),
    onRefresh = { viewModel.refresh() },
) {
    LazyColumn {
        items(30) { index ->
            // TODO: list items
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

请参阅文档了解更多详细信息。