0

I have a StaticLayout that AbsoluteSizeSpan is applied for each line. How to get size of lines in this layout?

Nam Nô
  • 31
  • 6

1 Answers1

0

try this

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 ());
}