Vitaliy Zarubin
05/20/2021, 4:40 PMnitrog42
05/20/2021, 5:00 PMsoftWrap = false
toonitrog42
05/20/2021, 5:01 PMnitrog42
05/20/2021, 5:02 PMRow(verticalAlignement = Alignement.Center)
would do the same without the constraint (but maybe you have more things to add to your cell)Vitaliy Zarubin
05/20/2021, 5:03 PMVitaliy Zarubin
05/20/2021, 5:04 PMFunkyMuse
05/20/2021, 5:04 PMVitaliy Zarubin
05/20/2021, 5:06 PMVitaliy Zarubin
05/20/2021, 5:13 PMnitrog42
05/20/2021, 5:20 PMnitrog42
05/20/2021, 5:21 PMVitaliy Zarubin
05/20/2021, 5:23 PMFunkyMuse
05/20/2021, 5:44 PMnitrog42
05/20/2021, 5:52 PMnitrog42
05/20/2021, 5:53 PM@Composable
fun Card() {
Surface(elevation = 2.dp) {
ConstraintLayout(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
) {
val (box, name) = createRefs()
Box(
Modifier
.size(56.dp)
.background(Color.Red)
.constrainAs(box) {
linkTo(top = <http://parent.top|parent.top>, bottom = parent.bottom, start = parent.start, end = parent.end, horizontalBias = 0f)
}) {
}
Text(text = "very very long text very very long text very very long text very very long text very very long text very very long text",
maxLines = 1,
overflow = TextOverflow.Ellipsis,
softWrap = false,
modifier = Modifier
.constrainAs(name) {
linkTo(start = box.end, end = parent.end, top = <http://box.top|box.top>, bottom = box.bottom)
width = Dimension.fillToConstraints
}
)
}
}
}
nitrog42
05/20/2021, 5:54 PMwidth = Dimension.fillToConstraints
The issue in your code was that you don't specify that your Text should have its width constrainednitrog42
05/20/2021, 5:54 PMVitaliy Zarubin
05/20/2021, 5:56 PMnitrog42
05/20/2021, 5:56 PMnitrog42
05/20/2021, 5:57 PMVitaliy Zarubin
05/20/2021, 5:57 PMfillMaxWidth(.2f) & .fillMaxWidth(.9f)
not goodnitrog42
05/20/2021, 5:57 PMnitrog42
05/20/2021, 5:59 PMVitaliy Zarubin
05/20/2021, 6:04 PM