'get real line by line from textView
is it possible to get real line by line value from textView? Even if it's sizable, i want to get every line in forEach.My textView is pinch zooming which means there's more and less lines when we zoom text. I tried like that but in every change lines are still the same, like in the beginning
val vto = textView.viewTreeObserver
vto.addOnGlobalLayoutListener {
val lines = mutableListOf<CharSequence>()
val lineCount: Int = textView.lineCount
for (line in 0 until lineCount) {
val start = textView.layout.getLineStart(line)
val end = textView.layout.getLineEnd(line)
val substring = textView.text.subSequence(start, end)
lines.add(substring)
Log.d("lines",lines.toString())
}
}
Number of lines is changing, but lines are still the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
