Susheel
04/14/2025, 7:00 PMcom.projectname.consumer.ui.BaseConsumerComposeBottomSheetModalFragment
, where I am extending the class and overriding a @Composable
function called ComposeBottomSheetContent()
. Simply placing a LazyColumn
, with zero items, causes the following error:
java.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 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.
Susheel
04/14/2025, 7:02 PMLazyColumn
so I wanted to set a fixed height but I had a requirement for the modal to be entire screen or at least 90 percent of height. Fixed height defined by dp
wouldn't make sense with various device types.
So after trying this
LazyColumn( modifier = Modifier.fillMaxHeight(0.9f) // Takes 90% of available height) { // Your items here}
still seeing same issueChrimaeon
04/14/2025, 7:04 PMComposeView
layout in the Fragment?Chrimaeon
04/14/2025, 7:05 PMChrimaeon
04/14/2025, 7:07 PMSusheel
04/14/2025, 7:08 PMSusheel
04/14/2025, 7:08 PMval windowHeight = LocalWindowInfo.current.bounds.height.toDp()
LazyColumn(
modifier = Modifier.height(windowHeight * 0.9f)
) {
// Your items
}
maybe this can work? There's probably a cleaner solutionChrimaeon
04/14/2025, 7:09 PMSusheel
04/14/2025, 7:09 PMChrimaeon
04/14/2025, 7:10 PMComposeView
that renders your Composable
Susheel
04/14/2025, 7:11 PMChrimaeon
04/14/2025, 7:11 PMChrimaeon
04/14/2025, 7:17 PMSusheel
04/14/2025, 7:18 PM