Canvas 作为绘制文本时,使用FontMetrics对象,计算位置的坐标。

上图其实是通过代码画出来的,具体代码如下:
另外:Paint类有两个方法
descent():the distance below the baseline(baseline以下的height)
所以ascent() + descent() 可以看成文字的height。
到此为止,怎么获取文字的height和width都已经揭晓了:
获取height : mPaint.ascent() + mPaint.descent()
获取width : mPaint.measureText(text)