1.计算文字长度
计算文字总长度:TextView.getPaint().measureText(String text)
计算某一行文字实际长度:TextView.getLayout().getLineWidth(int line)
TextView.getLayout()可能为空
tvAreaName.post(new Runnable() {
@Override
public void run() {
Layout l = tvAreaName.getLayout();
if (l != null) {
if (l.getEllipsisCount(l.getLineCount()-1) > 0){
Log.d(TAG, "Text is ellipsized");
}else{
Log.d(TAG, "Text is not ellipsized");
}
}
}
});