I want a composable to have a max height of 80%. I...
# compose
t
I want a composable to have a max height of 80%. Is there a way to do that other than this?
Copy code
BoxWithConstrain {
   val maxHeight = maxHeight
   Box(
     Modifier.heightIn(min = 0.dp, max = maxHeight * .8f)
   )
}
a
Copy code
Box(
    modifier = Modifier.layout { measurable, constraints ->
        val placeable = measurable.measure(
            constraints.copy(maxHeight = (constraints.maxHeight * 0.8f).roundToInt())
        )
        layout(placeable.width, placeable.height) {
            placeable.place(0, 0)
        }
    }
)
­čĹî 3
Ô׼ 2
t
Thanks Albert. Imma wrap this in custom modifier