开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜