[英]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.