I want to get the number of characters which are visible in TextView
when we have applied android:ellipsize
in TextView
. Suppose i have "This is dummy top stories title with multiline, This is dummy top stories title with multiline." text and i have set "android:ellipsize="end" android:maxLines="2""
these properties in my Textview
, so it will cut down some text and show the 3 dots. Now i want the nuumber of characters which are visible.
Asked
Active
Viewed 1,111 times
1

Sonal Bharwani
- 61
- 11
-
Please explain your problem briefly, you can post here its relevant screenshot too. So, I better understand – Fenil Patel Dec 20 '17 at 06:19
-
try this https://stackoverflow.com/a/15567519/8089770 – Vidhi Dave Dec 20 '17 at 06:37
1 Answers
0
In case of singleLine
TextView
:stringLength - textView.length()
would give how much text is not shown or ellipsized away in device.
Same way in case of multiline
TextView
you can use:Layout textViewLayout = textview.getLayout();
textViewLayout.getEllipsisCount(textViewLayout.getLineCount()-1)
As per Documentation at developer.android.com
getEllipsisCount(int line)
Returns the number of characters to be ellipsized away, or 0 if no ellipsis is to take place.
Note: getEllipsisCount
must be used after textview is visible/drawn.

Er. Kaushik Kajavadara
- 1,657
- 2
- 16
- 37
-
-
`textViewLayout.getEllipsisCount(textViewLayout.getLineCount()-1)` is returning 0 when string value is too large like approx 8000-9000 characters. – Sonal Bharwani Dec 21 '17 at 10:33