Joao Sardinha
Joao Sardinha

Reputation: 3423

Check if a string is too big to fit in a TextView

I have an EditText, a TextView and a Button. I want to check whether the string from EditText is too big or not to fit the TextView, if not I want to append "..." to the string, so if I write "That's a nice coat" and that's too big to fit in the TextView it shows "That's a ni...". I can't add more lines to the TextView to make it fit.

Upvotes: 3

Views: 850

Answers (1)

nitinkumarp
nitinkumarp

Reputation: 2160

Just use maxLines=1 and ellipsize=end in your TextView

if in code, use mText.setEllipsize(TextUtils.TruncateAt.END)

Upvotes: 4

Related Questions