Rect bounds = new Rect();
Paint textPaint = textView.getPaint();
textPaint.getTextBounds(text,0,text.length(),bounds);
int height = bounds.height();
int width = bounds.width();
Paint textPaint = textView.getPaint();
textPaint.getTextBounds(text,0,text.length(),bounds);
int height = bounds.height();
int width = bounds.width();
本文介绍了一种使用Paint对象获取文本尺寸的方法。通过创建矩形边界并利用getTextBounds()函数,可以计算出文本的高度和宽度。
7275

被折叠的 条评论
为什么被折叠?



