Kurlicue Kurlicue - 1 year ago 118
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 Source

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download