views:

68

answers:

2

I have a TextView that is a single line. How can I add ellipses (...) if the text is too long?

+2  A: 

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

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

Remember to use it when you want ellipses if the text reaching its parents width.

Charlie Sheen
A: 

Be aware of some issues by using the function: http://stackoverflow.com/questions/3769105/android-something-better-than-androidellipsizeend-to-add-to-truncated

however, its still the most robust way to do it.

OneWorld