I have a TextView, which is a single line. How to add ellipses (...) if the text is too long?
In your XML file, you can use: android:ellipsize="end" .
android:ellipsize="end"
In .java code you can use: yourTextView.setEllipsize(TextUtils.TruncateAt.valueOf("END")); .
yourTextView.setEllipsize(TextUtils.TruncateAt.valueOf("END"));
Remember to use it if you want to use ellipses if the text reaches its parent width.
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.