【发布时间】:2014-08-03 12:17:31
【问题描述】:
我在代码中使用以下 sn-p 来检查字符串是否足够小以适合文本视图。
private int findLengthThatFits (TextView view, String text) {
float textWidth = view.getPaint().measureText(text);
if (textWidth >= view.getMeasuredWidth ()){
//do somethings
}
//other stuff
}
但是view.getMeasuredWidth () 不断返回0.0。有谁知道我可以如何解决这个问题?我使用How to find android TextView number of characters per line? 作为参考。
【问题讨论】:
标签: android text textview size width