I have a TextView in my layout which is wrap_content in layout_width. It is limited to maximum of 15 characters so I\'m using maxLength.
I need to end this TextView
You can just modify the String
when it's length is above 20 to add the ellipsize.
Very Important: ellipsize = "end"
only works when maxLength
is set to a value that is more than the number of characters on one line.
You can use wrap_content
if you align the TextView's end and start to any other view(s).
use this android:ellipsize="end"
remove the line from xml
android:lines="1"
android:maxLines="1"
You cannot use both maxLength
and Ellipsize
although you can define Maximum EMS
see the example below
<TextView
android:id="@+id/tv_hist_source_lang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxEms="8"
android:maxLines="1"
android:text="TextView"
android:textAppearance="?android:attr/textAppearanceMedium" />
You can use
android:maxWidth="100dp"
android:maxLines="1"
android:ellipsize="end"
Only this works for me.