Please tell me what's wrong
# compose
v
Please tell me what's wrong
n
use
softWrap = false
too
and you it would be easier to use a simple Row instead of your ConstraintLayout
Row(verticalAlignement = Alignement.Center)
would do the same without the constraint (but maybe you have more things to add to your cell)
v
Not work :(
I am aware of Row, I want to deal with ConstraintLayout. In xml it works.
f
move .fillMaxWidth before you apply the .constraintAs
v
xml
n
hmm actually you should remove fillMaxWidth don't you think ?
you are putting a constraint on the start/end then filling the space
v
fillMaxWidth != 0dp ? I've tried removing fillMaxWidth. This does not work.
f
Try to constrain the top text to parent.top and to parent.bottom
n
no, I think the issue comes from the ConstraintLayout 😄
here, this will work:
Copy code
@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
                    }
            )
        }
    }
}
you need this part :
width = Dimension.fillToConstraints
The issue in your code was that you don't specify that your Text should have its width constrained
🙏 1
👍 1
in xml that is something that we have to specify usually, maybe it's a default value here but it shouldn't
v
It works, but I think it's not good 🙂 Hopefully ConstraintLayout gets fixed
n
what is not good ?
oh yeah, look at my answer above
v
Copy code
fillMaxWidth(.2f) & .fillMaxWidth(.9f)
not good
v
The end. ConstraintLayout is working! 🥳
🤦 1
👍 1