loloof64
11/24/2020, 7:49 PM@Composable
fun SimpleZone(modifier: Modifier) {
val backgroundColor = Color(0xCAD63B60) // purple
val cellColor = Color(0xFFFFCE9E) // brown
Column(modifier = modifier.background(backgroundColor)) {
Row(modifier = Modifier.fillMaxHeight(0.1f).background(cellColor)) {
}
}
}
@Preview
@Composable
fun SimpleZonePreview() {
SimpleZone(modifier = Modifier.size(100.dp))
}
Nate Ridderman
11/24/2020, 8:02 PMfillMaxHeight
doesn’t work because the height is already specified in the modifier (in this case inherited from the parent). If you “reset” this by adding
.wrapContentHeight
before it, it resizes as you desire.Adam Powell
11/24/2020, 8:08 PMAdam Powell
11/24/2020, 8:15 PMColumn(Modifier.size(100.dp).background(Color.Blue)) {
Row(Modifier.fillMaxHeight(0.1f).fillMaxWidth().background(Color.Red)) {
}
}
Adam Powell
11/24/2020, 8:16 PMColumn
relaxes the minimum width constraint for childrenloloof64
11/24/2020, 8:19 PMNate Ridderman
11/24/2020, 8:21 PMNate Ridderman
11/24/2020, 8:27 PMAdam Powell
11/24/2020, 8:30 PMModifier.size(100.dp).fillMaxWidth()
then yes, the fillMaxWidth()
is then a no-op. size
sets both the min and max constraints to the same value, and fillMaxWidth
sets the minimum width constraint to the maximum width constraintAdam Powell
11/24/2020, 8:30 PMAdam Powell
11/24/2020, 8:31 PMAdam Powell
11/24/2020, 8:32 PMfillMaxHeight(0.1f)
for example, sets both the min and max height to 0.1f * incomingMaxHeight
Nate Ridderman
11/24/2020, 8:37 PM