开发者

drawPosText() in android.graphics.Canvas, What is origin?

drawPosText(char[] text, int index, int count, float[] pos, Paint paint) Draw the text in the array, with each character's origin specified by the pos array.

Does anyo开发者_StackOverflow中文版ne know where exactly does drawPosText consider the "origin" to be, since you are specifying "origin" as coordinate pairs; i.e., is it bottom-left of character, center, what?

Also how does drawPosText calculate character height when it draws?


Ah, I spent a chunk of yesterday playing with centering some text!

If you're in left alignment, the text origin is the bottom left corner. If you're in center alignment, the text is centered horizontally and the origin is bottom center.

You can get the height of the text with

Math.abs(p.ascent()) + p.descent()

where p is your Paint.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜