canvas.drawRoundRect(rectF, 10f, 10f, mAwakenPointPaint);
String res = "安静啊啊家";
Paint.FontMetrics fontMetrics = mAwakenPointPaint.getFontMetrics();
float baseline = rectF.centerY() - (fontMetrics.top / 2) - (fontMetrics.top / 2);
mAwakenTextPaint.setTextAlign(Paint.Align.CENTER);
canvas.drawText(res, rectF.centerX(), baseline, mAwakenTextPaint);
自定义view文字在矩形里居中
最新推荐文章于 2024-03-11 14:04:15 发布