iturki iturki - 1 year ago 98
Android Question

Can I limit TextView's number of characters?

What I have now is a ListView of TextView elements. each TextView element displays a text (the text length varies from 12 words to 100+). What I want is to make these TextViews display a portion of the text (let's say 20 word or roughly 170 chars).

How to limit the TextView to a fixed number of characters?

Answer Source

Here is an example. I limit the sizewith the maxLength attribute, limit it to a single line with maxLines attribute, then use the ellipsize=end to add a "..." automatically to the end of any line that has been cut-off.

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