Sos*_*kin 5 android android-jetpack-compose
我有一个,我想在内部Column(modifier = Modifier.verticalScroll(mainScrollState))使用而不明确指定高度。LazyColumnColumnLazyColumn
现在它给了我 java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed.
我尝试使用NestedScrollConnection但它没有给我正确的解决方案。有什么解决方法吗?
我的整个可组合项如下所示:
Scaffold() {
Column() {
Column() {
LazyColumn { ... }
}
Column() { ... }
}
}
Run Code Online (Sandbox Code Playgroud)
小智 0
我使用这个解决方法
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
) {
LazyColumn(
modifier = Modifier.heightIn(2000.dp) // set the maximum height possible in your case
) {
// your content
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用heightIn(),这样 compose 就会知道元素的确切高度。这与wrapContentHeight类似,但有允许的最大高度
不过我认为它更适合少量物品
| 归档时间: |
|
| 查看次数: |
4770 次 |
| 最近记录: |