由于某些原因,LazyColumn
不使用鼠标单击并移动手势滚动。到目前为止,它只适用于鼠标轮。对于LazyRow
,也不可能用鼠标滚轮滚动。看起来懒散的行对于桌面来说是无用的。
是否有可能在LazyRow
和LazyColum
上启用单击和移动手势。如果没有,那么至少可以用鼠标轮滚动LazyRow
吗?
我使用了这个最小的可重复的例子来测试滚动
@Composable
@Preview
fun App() {
var text by remember { mutableStateOf("Hello, World!") }
MaterialTheme {
LazyRow(modifier = Modifier.fillMaxSize()) {
repeat(100) {
item {
Text("Test Test Test Test $it ")
}
}
}
}
}
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
App()
}
}
发布于 2022-01-20 02:33:40
这就是预期的行为。
所有可滚动的组件(包括LazyColumn
) (目前)只在桌面上使用鼠标滚轮滚动事件。
可滚动组件不应响应鼠标拖动/移动事件。
下面是一个基本示例,说明如何将拖动支持添加到组件中:
val scrollState = rememberLazyListState()
val coroutineScope = rememberCoroutineScope()
LazyRow(
state = scrollState,
modifier = Modifier
.draggable(
orientation = Orientation.Horizontal,
state = rememberDraggableState { delta ->
coroutineScope.launch {
scrollState.scrollBy(-delta)
}
},
)
) {
items(100) {
Text("Test Test Test Test $it")
}
}
https://stackoverflow.com/questions/70774033
复制相似问题