Have the content fill (possibly only partially) the [Constraints.
FillHalfHeightModifier
@Composable
fun FillHalfHeightModifier() {
Box(Modifier.requiredSize(100.dp).background(Color.Red), contentAlignment = Alignment.Center) {
// The inner Box will be (30.dp x 50.dp).
Box(Modifier.requiredWidth(30.dp).fillMaxHeight(0.5f).background(color = Color.Magenta))
}
}
SimpleFillHeightModifier
@Composable
fun SimpleFillHeightModifier() {
Box(Modifier.fillMaxHeight().background(Color.Red), contentAlignment = Alignment.Center) {
Box(Modifier.size(100.dp).background(color = Color.Magenta))
}
}