I have a Column(modifier = Modifier.verticalScroll(mainScrollState)) and I want to use LazyColumn inside Column WITHOUT specifying height of LazyColumn explicitly.
Now it gives me java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed.
I tried using NestedScrollConnection but it didn't give me right solution. Any workarounds?
My whole composable looks like:
Scaffold() {
Column() {
Column() {
LazyColumn { ... }
}
Column() { ... }
}
}
I use this workaround
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
) {
LazyColumn(
modifier = Modifier.heightIn(2000.dp) // set the maximum height possible in your case
) {
// your content
}
}
You may use heightIn(), so compose will know the exact height of element. This works like wrapContentHeight, but there is a maximum height allowed
I think it's more suitable for small number of items, though
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With