https://kotlinlang.org logo
m

Marcin Środa

08/23/2021, 1:26 PM
Hey, trying to place an item after ellipsized text. When text is not ellipsized it works fine, but when overflow happens, the icon is not displayed. Any ideas? 🧵
Copy code
Row {
        Text(
            text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
            maxLines = 1,
            overflow = TextOverflow.Ellipsis,
        )
        Icon(
            imageVector = Icons.Filled.ArrowRight,
            contentDescription = "Icon",
        )
    }
a

Adam Powell

08/23/2021, 1:40 PM
Row measures its children in order by default. If the text is ellipsizing it's because you're out of horizontal space and there's none left for the icon either. Try
Modifier.weight(1f, false)
on the
Text
. That will request the
Text
be measured after unweighted children.
m

Marcin Środa

08/23/2021, 4:38 PM
Thanks! 🙂
👍 1
5 Views