我有一个StaticLayout,其中AbsoluteSizeSpan应用于每行。如何获得此布局中的线条尺寸?
尝试一下
private int charPerLine(TextView textView){
String s = "";
for (int i = 0; i <= 1000; i++) {
s+="X";
if(isTooLarge(textView,s)){
return i;
}
}
return 1000;
}
private boolean isTooLarge (TextView textView, String text) {
float textWidth = textView.getPaint().measureText(text);
return (textWidth >= textView.getMeasuredWidth ());
}