【发布时间】:2021-08-16 14:54:28
【问题描述】:
我有一列有很多项目;基于滚动,我想显示/隐藏浮动操作按钮,如果滚动向下,隐藏它,如果滚动向上,显示它。
我的代码部分工作,但滚动有问题。下面是代码。需要帮助。
Column(
Modifier
.background(color = colorResource(id = R.color.background_color))
.fillMaxWidth(1f)
.verticalScroll(scrollState)
.scrollable(
orientation = Orientation.Vertical,
state = rememberScrollableState {
offset.value = it
coroutineScope.launch {
scrollState.scrollBy(-it)
}
it
},
)
) { // 10-20 items }
基于偏移值(无论是正/负),我保持FAB的可见性。
【问题讨论】:
-
FloatingActionButton 在哪里?
-
它在Scaffold,Column在Scaffold的内容下
-
lazyColumn 是一个选项而不是一个可滚动的列吗?
-
Lazy column 存在从网络加载图像的问题,我上次尝试过,这就是我现在使用 Column 的原因。无论如何,我只需要知道,如何检测上/下滚动?
标签: android scroll android-jetpack android-jetpack-compose vertical-scrolling