0

我有一个 AbsoluteSizeSpan 应用于每一行的 StaticLayout。如何在此布局中获取线条的大小?

4

1 回答 1

0

尝试这个

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 ());
}
于 2020-02-27T08:13:50.990 回答