Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

End the ellipse problem with TextViews

Whoa SDK, whoa...

So I'm attempting to add an ellipse to the end of my TextView (single line) before it runs off screen. I've read that ellipses are broke (developing for 2.1)? After Google searching, everyone seems to suggest setting inputType to text and maxLines to 1 and you will get an ellipse.

There are two problems with this: 1) The text runs off the screen, but doesn't ellipse. I can tell the text is running off the screen because only a half of a character is showing at the edge of the screen, but it's not printing "..." instead. 2) When I have inputType set on my TextView, clicking my list item no longer works! There is no highlighting when you click and the onListItemClick handler does not fire!

So...

What can I do here?

I would like to note that there are two ways one could ellipse. If the entire word does not fit on the screen, hide the entire word and add an ellipse. Or, just take off enough characters so an ellipse will fit. Ideally, the latter is what I want.

Thanks for your help

like image 836
Andrew Avatar asked Jul 30 '10 17:07

Andrew


1 Answers

If you want to ellipsize, simply use android:singleLine="true", or android:ellipsize="end".

like image 89
Romain Guy Avatar answered Oct 29 '22 12:10

Romain Guy