Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to abbreviate a TextView?

I have a TextView that is a single line. How can I add ellipses (...) if the text is too long?

like image 689
Sheehan Alam Avatar asked Sep 24 '10 16:09

Sheehan Alam


People also ask

What is the text view?

This feature of the Text view upholds what type of content has to be shown to the user. For example, if there is a Heading, there are 6 types of heading that can be implemented have a look at the following image which contains the guidelines for the size of the text view and style of the text view which is recommended by Google’s Material Design.

Why should we use abbreviation for texting?

If you use Abbreviation for Texting in your text message instead of full words then it will enhance your speed to infinity. If we use abbreviations in our text messaging it will help us to save our time and sending your message to another person Faster than a lengthy text.

Is it “text abbreviations” or “ text abbreviations?

And by the way, the correct terminology is “texting abbreviations”—you may have also seen “text abbreviations,” but this vaguer term is incorrect. Here’s a tip: Want to make sure your writing always looks great?

Do you use text abbreviations in real life?

While we may not always use text abbreviations in real life or face-to-face conversations, they have become a language of their own in instant messaging and social media. Text abbreviations are shortened versions of commonly used words to help save characters in text messages, whereas acronyms are used to shorten entire phrases.


2 Answers

In your XML-file you can use: android:ellipsize="end".

In your .java code you can use: yourTextView.setEllipsize(TextUtils.TruncateAt.valueOf("END"));.

Remember to use it when you want ellipses if the text is reaching its parent's width.

like image 50
Wroclai Avatar answered Oct 11 '22 09:10

Wroclai


Be aware of some issues by using the function: Android: Something better than android:ellipsize="end" to add "..." to truncated long Strings?

however, its still the most robust way to do it.

like image 23
OneWorld Avatar answered Oct 11 '22 09:10

OneWorld