doubov
07/13/2020, 12:05 AM@Composable
fun Greeting(name: String) {
val state = state { TextFieldValue("Hello $name") }
Row(modifier = Modifier.fillMaxWidth() + Modifier.wrapContentHeight()) {
Box(modifier = Modifier.width(32.dp) + Modifier.fillMaxHeight(), backgroundColor = Color.Yellow)
Column(modifier = Modifier.weight(1f)) {
TextField(
modifier = Modifier.fillMaxWidth() + Modifier.wrapContentHeight(),
value = state.value,
onValueChange = {
state.value = it
}
)
Text(
text = "TextField text: ${state.value.text}",
modifier = Modifier.padding(vertical = 8.dp) + Modifier.fillMaxWidth() + Modifier.wrapContentHeight()
)
Text(text = "Finish", modifier = Modifier.fillMaxWidth() + Modifier.wrapContentHeight())
}
Box(modifier = Modifier.width(32.dp), backgroundColor = Color.Yellow)
}
}
Produces in my opinion, unexpected layout:doubov
07/13/2020, 12:06 AMdoubov
07/13/2020, 12:07 AMV Badalyan
07/13/2020, 12:08 AMdoubov
07/13/2020, 12:09 AMV Badalyan
07/13/2020, 12:09 AMV Badalyan
07/13/2020, 12:09 AMModifier.fillMaxWidth() + Modifier.wrapContentHeight(),
V Badalyan
07/13/2020, 12:10 AMV Badalyan
07/13/2020, 12:10 AMdoubov
07/13/2020, 12:11 AMdoubov
07/13/2020, 12:14 AMBox
Composables?doubov
07/13/2020, 12:14 AMV Badalyan
07/13/2020, 12:21 AMdoubov
07/13/2020, 12:23 AMBox(modifier = Modifier.width(32.dp) + Modifier.fillMaxHeight(), backgroundColor = Color.Yellow)
doubov
07/13/2020, 12:24 AMBox
, but it ends up taking up the whole height of the screendoubov
07/13/2020, 12:26 AMModifier.fillMaxWidth()
from the parent Row
just in case those Modifiers aren’t compatible as your said, but it’s still the same resultV Badalyan
07/13/2020, 12:59 AMV Badalyan
07/13/2020, 1:00 AMV Badalyan
07/13/2020, 1:00 AMmodifier = Modifier.width(32.dp) + Modifier.fillMaxHeight()
->
modifier = Modifier.width(32.dp).fillMaxHeight()
doubov
07/13/2020, 2:16 AMppvi
07/13/2020, 10:49 AMZach Klippenstein (he/him) [MOD]
07/13/2020, 1:28 PMpreferredHeight(IntrinsicSize.Max)
on your Row, as in the sample in the kdoc: https://developer.android.com/reference/kotlin/androidx/ui/layout/package-summary#(androidx.ui.core.Modifier).preferredHeight(androidx.ui.layout.IntrinsicSize)doubov
07/13/2020, 4:59 PMIntrinsicSize.Max
seems to do the trick. I was wary of using it since it is in Experimental state.Zach Klippenstein (he/him) [MOD]
07/13/2020, 4:59 PMSean McQuillan [G]
07/14/2020, 6:20 PMSean McQuillan [G]
07/14/2020, 6:35 PMfillMaxHeight
works this way – it's filling the maximum allowed height by the parent.
The parent specifying wrapContentHeight
does not add a second layout pass to resize it when its children are measured, but simply changes the min constraint to 0.Sean McQuillan [G]
07/14/2020, 6:37 PMwrap_content
or layout_weight
in Compose.doubov
07/15/2020, 4:13 AM