android canvas drawtext 字高

Paint pFont = new Paint();
Rect rect = new Rect();
pFont.getTextBounds("豆", 0, 1, rect);
Log.v(TAG, "height:"+rect.height()+"width:"+rect.width());

得到字高。

或者
float textHeight = mPait.getFontMetrics().descent - mPaint.getFontMetrics().ascent;

drawtext以baseline为基准去画的。注意位置。
posted on 2018-11-09 14:50  wp7ers  阅读(445)  评论(0编辑  收藏  举报