Measure text length before rendering
I have a widget where I need to display some text on one row. If the text does not fit, I wo开发者_JAVA百科uld like to show as much as possible and end the text with "..." to show that not all text is displayed. Is there a way to discover how long the displayed text will be before rendering the widget, so that I can replace the last part of the text with "..."?
Cheers,
You don't need to do that - a TextView can do it for you.
myTextView.setSingleLine(true);
myTextView.setEllipsize(TextView.TruncateAt.END);
精彩评论