首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

关于Canvas.drawText中xy位置有关问题

2013-01-25 
关于Canvas.drawText中xy位置问题问:canvas.drawText(3, x, y, paint)x和y是指画得时候数字3中心的坐标

关于Canvas.drawText中xy位置问题
问:canvas.drawText("3", x, y, paint);  x和y是指画得时候数字3中心的坐标吗?还是左上角的坐标?
x答:默认是‘3’这个字符的左边在屏幕的位置,如果设置了paint.setTextAlign(Paint.Align.CENTER);那就是字符的中心,y是指定这个字符baseline在屏幕上的位置。

public void drawText (String text, float x, float y, Paint paint)
Since: API Level 1 Draw the text, with origin at (x,y), using the specified paint.
The origin is interpreted based on the Align setting in the paint.
Parameters
text The text to be drawn
x The x-coordinate of the origin of the text being drawn
y The y-coordinate of the origin of the text being drawn
paint The paint used for the text (e.g. color, size, style)

热点排行