1.只得到字符宽度
//直接返回参数字符串所占用的像素宽度
Paint paint = new Paint();
width = paint.measureText(str);
有一些view可以直接得到paint,如textview,
TextPaint paint = noticeView.getPaint();
String text = ""+noticeView.getText();
int w = (int) paint.measureText(text);
2.得到字符矩形区域大小
Paint paint = new Paint();
Rect rect = new Rect(); //返回包围整个字符串的最小的一个Rect区域
paint.getTextBounds(str, , , rect); strwid = rect.width();
strhei = rect.height();