Kurlicue Kurlicue - 7 months ago 14
Java Question

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.

Answer

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

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

Comments