[英]Jetpack Compose LazyRow and LazyColumn for category section auto scrolling
[英]Compose for Desktop LazyRow/LazyColumn not scrolling with mouse click
由于某种原因LazyColumn
不会通过鼠标单击和移动手势滚动。 到目前为止,它仅适用于鼠标滚轮。 对于LazyRow
,也无法使用鼠标滚轮滚动。 似乎惰性行对于 Compose for desktop 没用。
是否可以在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()
}
}
这是预期的行为。
所有可滚动组件(包括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")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.