Mohammad Sianaki
09/27/2020, 12:22 PMModifier.fillMaxHeight()
is not working, can some one explain me what I am doing wrong?
Row(Modifier.padding(horizontal = 32.dp, vertical = 16.dp).background(Color.Red)) {
Column(Modifier.fillMaxHeight().weight(1f).background(Color.Cyan)) {
Row {
Image(
asset = imageResource(id = Drawables.mappin),
Modifier.gravity(Alignment.CenterVertically)
)
Column(Modifier.padding(start = 16.dp)) {
Text(
text = "Address", style = TextStyle(
color = Color.Black.copy(alpha = 0.7f),
fontSize = 20.sp
)
)
Text(
text = "House # 2, Road # 5, Green Road Dhanmondi, Dhaka, Bangladesh",
style = TextStyle(color = Color.Gray)
)
}
}
Row {
Image(
asset = imageResource(id = Drawables.clock),
Modifier.gravity(Alignment.CenterVertically)
)
Column(Modifier.padding(start = 16.dp)) {
Text(
text = "Daily Practice", style = TextStyle(
color = Color.Black.copy(alpha = 0.7f),
fontSize = 20.sp
)
)
Text(
text = "Monday - Friday Open till 7 Pm",
style = TextStyle(color = Color.Gray)
)
}
}
}
Image(
asset = imageResource(id = Drawables.map),
modifier = Modifier.fillMaxHeight().weight(1f)
)
}
Zach Klippenstein (he/him) [MOD]
09/28/2020, 1:48 AMYann Badoual
09/28/2020, 7:26 AMmatchParentHeight
, a bit like the matchParentSize
we have in a StackScope
I've been looking for a way to make every children in a row match its parent height. Only answer I have to far is using constraint layoutMohammad Sianaki
09/28/2020, 10:07 AMMihai Popa
09/28/2020, 10:27 AMRow(Modifier.padding(horizontal = 32.dp, vertical = 16.dp).size(IntrinsicSize.Max).background(Color.Red))
. This will premeasure the height of the Row
and then when the Column
does fillMaxHeight
the height filled will be the premeasured one rather than the `Row`'s available height.Mihai Popa
09/28/2020, 10:29 AMConstraintLayout
. Even if the layout is expressed in a different way, it will do a similar premeasurement under the hood.Yann Badoual
09/28/2020, 11:06 AMsize(IntrinsicSize.MAX)
doesn't seem to exist (anymore?), use instead:
preferredHeight(IntrinsicSize.Max)
Did the trick for me
Thanks for the tip @Mihai Popa
(Though it's marked as experimental layout api)Mihai Popa
09/28/2020, 11:10 AMheight
, which should exist as well as preferredHeight
.Yann Badoual
09/28/2020, 11:14 AMheight
, only preferredHeight
Mihai Popa
09/28/2020, 11:21 AM