Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the ellipsized text in a TextView

How do I get the text that has been truncated by Android into an ellipsis?

I have a textview:

<TextView
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:singleLine="true"
    android:text="Um longo texto aqui de exemplo" />

On a device this TextView is shown like this:

"Um longo texto a..."

How do I get the rest of the text?

I am looking for something like getRestOfTruncate() which would return "qui de exemplo".

like image 535
ademar111190 Avatar asked Jun 14 '12 22:06

ademar111190


1 Answers

String text = (String) textView.getText().subSequence(textView.getLayout().getEllipsisStart(0), textView.getText().length());
like image 101
Sudar Nimalan Avatar answered Oct 04 '22 13:10

Sudar Nimalan