Hello I'm using ConstraintLayout and I can make a ...
# compose
p
Hello I'm using ConstraintLayout and I can make a box grow with a child Box without cutting the text of the children when the text of the first is too small. Is there any way to set the
width = Dimension.fillToConstraint
and then say that the first box has the min width as the second Box? The only constraint is that the first box can group and it makes the second one bigger, but the min width of the first one should be the same width as the second box. I add a reproducible code down below.
Copy code
ConstraintLayout() {
    val (title, description) = createRefs()
    Box(
        modifier = Modifier
            .padding(start = 4.dp)
            .background(color = Red)
            .padding(horizontal = 16.dp)
            .constrainAs(title) {
                top.linkTo(<http://parent.top|parent.top>)
                start.linkTo(parent.start)
                end.linkTo(parent.end)
                width = Dimension.fillToConstraints
            },
        contentAlignment = Alignment.Center
    ) {
        Text(text = "Dynamic value", maxLines = 1)
    }

    Box(
        modifier = Modifier
            .padding(end = 4.dp)
            .background(Color.Magenta)
            .padding(
                bottom = 5.dp, start = 8.dp, end = 16.dp, top = 4.dp
            )
            .constrainAs(description) {
                top.linkTo(<http://title.top|title.top>, margin = 16.dp)
                start.linkTo(parent.start)
                end.linkTo(parent.end)
                bottom.linkTo(parent.bottom)
            },
        contentAlignment = Alignment.Center
    ) {
        Text(text = "Fixed Value")
    }
}