protected void onDraw(Canvas canvas){
Float x,y;
FontMetricsInt fontMetrics = paint.getFontMetricsInt();
y = getHeight()/2 - (fontMetrics.ascent+fontMetrics.descent)/2;
canvas.drawText(text,x,y,paint);
super.onDraw(canvas);
}
自定义控件时绘制文字居中
最新推荐文章于 2020-07-23 16:51:59 发布