chanjungskim
12/19/2022, 3:17 AMjava.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There are could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.
errorKirill Grouchnikov
12/19/2022, 3:28 AMchanjungskim
12/19/2022, 3:29 AMmattinger
12/19/2022, 4:50 AMmattinger
12/19/2022, 4:53 AMchanjungskim
12/19/2022, 7:02 AMSupplementSearchResultCard
So, it will be
LazyColumn{
items(cardList){ cardContent ->
SupplementSearchResultCard(cardContent)
}
}
I'd like to create like nested one.chanjungskim
12/19/2022, 7:04 AMColum{
SupplementSearchResultCard(list)
}
and it solved. but, now I want to do like this.
Colum{
Text(...)
OtherCompoableFuncions(...)
SupplementSearchResultCard(list1)
SupplementSearchResultCard(list2)
}
It doesn't crash but this make the last card scrollable only in it.efemoney
12/19/2022, 10:41 AMLazyColumn
2. Use a Column with toggleable scrolling (ie control the scroll via a flag/modifier from outside)efemoney
12/19/2022, 10:44 AMSupplementSearchScreen(…, scrollEnabled: Boolean = false) {
Column(
modifier = <existing-modifier>
.run { if (scrollEnabled) } verticalScroll(...) else this }
)
}
Then you can turn off scrolling whenever that composable is nested andmturn it on when its used standalonechanjungskim
12/19/2022, 10:45 AMchanjungskim
12/19/2022, 10:46 AMefemoney
12/19/2022, 10:48 AMchanjungskim
12/19/2022, 10:53 AMefemoney
12/19/2022, 10:56 AMchanjungskim
12/19/2022, 11:23 AMsealed class SearchUi{
data class Title(val text: String): SearchUi
data class SearchBar(val text: String): SearchUi
data class ACard(val list: List<Card>): SearchUi
data class BCard(val list: List<Card>): SearchUi
}
and then...
LazyColumn{
items(searchUi){ item ->
when(item){
is Title -> Text(item.text)
is SearchBar -> SearchBar(item.text)
is ACard -> ACard(item.list)
is BCard -> BCard(item.list)
}
}
}
chanjungskim
12/19/2022, 11:25 AMKirill Grouchnikov
12/19/2022, 1:29 PM