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:V Badalyan
07/13/2020, 12:08 AMdoubov
07/13/2020, 12:09 AMV Badalyan
07/13/2020, 12:09 AMModifier.fillMaxWidth() + Modifier.wrapContentHeight(),
doubov
07/13/2020, 12:11 AMBox
Composables?V Badalyan
07/13/2020, 12:21 AMdoubov
07/13/2020, 12:23 AMBox(modifier = Modifier.width(32.dp) + Modifier.fillMaxHeight(), backgroundColor = Color.Yellow)
Box
, but it ends up taking up the whole height of the screenModifier.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 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 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.wrap_content
or layout_weight
in Compose.doubov
07/15/2020, 4:13 AM