【发布时间】:2022-01-15 06:37:09
【问题描述】:
我想在我的 LazyColumn 或 Column 中禁用滚动。
Modifier.scrollable(state = rememberScrollState(), enabled = false,orientation = Orientation.Vertical)
或
Modifier.verticalScroll(...)
不起作用。
这是我的代码:
Column(
modifier = Modifier
.fillMaxSize()
) {
Box(
modifier = Modifier
.padding(15.dp)
.height(60.dp)
.clip(RoundedCornerShape(30))
) {
TitleSection(text = stringResource(id = R.string...))
}
LazyColumn(
contentPadding = PaddingValues(start = 7.5.dp, end = 7.5.dp, bottom = 100.dp),
modifier = Modifier
.fillMaxHeight()
) {
items(categoryItemContents.size) { items ->
CategoryItem(categoryItemContents[items], navController = navController)
}
}
}
【问题讨论】:
-
欢迎使用 StackOverflow。见How do I ask a good question。这听起来像是您试图通过将
Modifier.scrollable添加到LazyColumn来禁用滚动。它不是这样工作的,新的修饰符正在添加一个新的滚动视图,你不能用新的修饰符修改现有的。如果它是应用于Column的唯一可滚动修饰符,则您的代码将起作用。如果我没猜对,请通过添加minimal reproducible example 来编辑您的问题 -
我更新了我的问题。如何编辑现有的可滚动修饰符?看起来我必须使用
LazyListState,但使用此解决方案How to disable and enable scrolling in LazyColumn/LazyRow in Jetpack Compose?,LazyListState的类型为 Unit。 -
如果你关注my answer,则不需要
LazyListState。
标签: android kotlin android-jetpack-compose android-jetpack lazycolumn