android中字体宽度获得

来源:互联网 发布:js 左右滑动切换特效 编辑:程序博客网 时间:2024/04/29 06:45

方法1:

Rect bounds = new Rect();mPaint.getTextBounds(mText,0,mText.length(),bounds);textWidth = bounds.width();

方法2:

textWidth = (int)mPaint.measureText(mText);

grepcode

原创粉丝点击