How to abbreviate TextView?

I have a TextView, which is a single line. How to add ellipses (...) if the text is too long?

+4
source share
2 answers

In your XML file, you can use: android:ellipsize="end" .

In .java code you can use: yourTextView.setEllipsize(TextUtils.TruncateAt.valueOf("END")); .

Remember to use it if you want to use ellipses if the text reaches its parent width.

+5
source

Remember some problems with the function: Android: something better than android: ellipsize = "end" to add "..." for truncated long lines?

however its still the most reliable way to do this.

+2
source

All Articles