robnik
12/17/2020, 6:01 PMText
to wrap to a second line to avoid pushing things off screen? Inside a screen-wide Column I have:
Row {
Text("A somewhat long line that needs to wrap probably")
Spacer(Modifier.width(3.dp))
Switch(model.foo, { model.foo = it })
}
The Text and Switch are overlapping a bit, and the Switch half pushed off screen.Vadim
12/17/2020, 6:42 PMRow {
Column(modifier = Modifier.weight(1f)) {
Text(title)
}
Column {
Switch(checked, onCheckedChange, enabled = enabled)
}
}
The key thing is .weight(1)
, also the parent of this Row
has constraint like .fillMaxWidth()
(not sure if this is a requirement). With these, text fills all available horizontal space and keeps Switch
aligned to the endLuke
12/17/2020, 7:35 PM.weight(1f)
, although I'm not sure the extra columns are necessary. You could try applying the weight directly on TextVadim
12/17/2020, 7:39 PMrobnik
12/17/2020, 8:34 PMLuke
12/17/2020, 9:06 PMweight/total weight
of the parent. Those without weight default to wrap content, and those with weight take their fraction of the remaining space