Android 获得画布中字体所占的像素长和宽【动态画图时很有用】

方法一:

Paint paint = new Paint();

Rect rect = new Rect();

paint.getTextBounds(String, int start, int end, rect);

width = rect.width();

height = rect.height();

方法二:

strWidth = paint.measureText(text);
posted @ 2013-08-09 14:09  邪天殇  阅读(419)  评论(0编辑  收藏  举报