How to add reticence if content leaks from Android layout?

Asked

Viewed 690 times

3

How to add ellipsis if content leaks from 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 reticence in case there is leakage of layout, for example, from "First Aid" to "First Aid..."

  • Try to limit the size of your Textview using the :Ems measure

  • I used Ems, but it breaks the line of text!

  • How do I make it delete the text that bursts the size, changing by reticence

1 answer

3

The TextView has an attribute called ellipsize, which, according to the documentation, allows the addition of ... automatically if the word is too big, instead of breaking in the middle.

In your case, use the attribute android:ellipsize="end" in his 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" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.