https://kotlinlang.org logo
#compose
Title
# compose
s

Socheat KHAUV

10/22/2020, 7:51 AM
@Vinay Gaba - I checked your constraint layout example from github (https://github.com/vinaygaba/Learn-Jetpack-Compose-By-Example) and see this file "ConstraintLayoutActivity.kt" and this function "SimpleConstraintLayoutComponent" if I change the title text to the following
Copy code
Text(
        maxLines = 2,
        overflow = TextOverflow.Ellipsis,
        text = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30", style = TextStyle(
        fontFamily = FontFamily.Serif,
        fontWeight =
        FontWeight.W900,
        fontSize = 14.sp,
)
then the title text will look become weird, I am not sure it is constraint layout bug or I missed out something.
🪲 1
t

tieskedh

10/22/2020, 11:10 AM
I think it's a bug: i believe it doesn't handle the offset well:
Copy code
fun textInConstraintWithOffset() = ConstraintLayout(
    Modifier.fillMaxSize()
) {
    val (text2Ref) = createRefs()
    Text(
        text = (1..100).joinToString("-"),
        color = Color.White,
        modifier = Modifier.constrainAs(text2Ref) {
            start.linkTo(parent.start, margin = 100.dp)
                end.linkTo(parent.end)
        }
    )
}
Same problem is with guideline or box like you do
v

Vinay Gaba

10/22/2020, 4:06 PM
Yeah I’ve seen the behavior differ across versions. I do think I should constraint the end of the title to the parent though…
4 Views