How to add ellipsis if content leaks from Android layout?

3

How do I add ellipses if content leaks from the Android layout?

For example: I have a very large text in my ActionBar , and instead of having to decrease it in size, I want it to add ellipsis if there is a layout leak, for example from "First Aid" to "First Soc ... "

    
asked by anonymous 04.06.2015 / 16:04

1 answer

3

TextView has an attribute called ellipsize , which, second documentation , allows the addition of ... automatically if the word is too large, rather than breaking in the middle.

In your case, use the android:ellipsize="end" attribute on your TextView , along with android:singleLine="true"

<TextView
    android:id="@+id/tv_test"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:singleLine="true" />
    
05.06.2015 / 20:11