How to show 3 dots at the end of text in textview
For one line text with a dot but now it's Deprecated so don't use singleLine
anymore
Thanks to this post I found that how to show dot after the end of text if we have more one line, it works for me :)
android:ellipsize="end"
android:maxLines="2"
Post here this answer because all answer here are for single line not for multiline
android:ellipsize
will works only with:
android:singleLine="true"
or
android:maxLines="#any number#"
android:scrollHorizontally="true"
Because maxLength truncate the text.
So you have to manage the label with code if you want to display only 50 char + dots, or let two line for the textview.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:scrollHorizontally="true"
android:text="Hello developer. please check this message for long length. max length to 50 characters."
android:textSize="20sp" />
Make a preset width for your TextView and add these attributes (Shout-out to @T-D)
android:ellipsize="end"
android:maxLines="1"
The maxLines will make sure that your text wont be shown in two lines and the ellipsize will add the three dots in the end.
Old Answer
android:ellipsize="end"
android:singleLine="true"