I would like to get the index of the last visible line in case the text in my
Text
composable overflows. I came across
TextLayoutResult.getLineEnd
that seems like it could help me in this case. However, i need to supply the
lineIndex
. How would i go about getting the
lineIndex
of the line that is overflowing?
samuel
07/31/2022, 1:13 PM
Copy code
Text(
text = "my text",
modifier = Modifier.fillMaxWidth(),
overflow = TextOverflow.Ellipsis,
onTextLayout = { textLayoutResult ->
if (textLayoutResult.didOverflowHeight || textLayoutResult.didOverflowWidth) {
val overFlowingLineIndex = textLayoutResult.getLineEnd(
// Using the first line here, but i would like to compute the the line index of the overflow
lineIndex = 0,
visibleEnd = true
)
}
},
)