我正在包含 bg 的 ImageView 上绘制速度计。我将此代码用于刻度和值
for (int i = 0; i < 270; i += 5) {
if (i % 30 == 0) {
scalePaint.setStrokeWidth(2f);
canvas.drawLine(3.55f * wQuarter, 2 * hQuarter,
3.78f * wQuarter, 2 * hQuarter, scalePaint);
canvas.drawText(String.valueOf(i), 3.5f * wQuarter,
2f * hQuarter, scalePaint);
} else {
scalePaint.setStrokeWidth(1.5f);
canvas.drawLine(3.65f * wQuarter, 2 * hQuarter,
3.78f * wQuarter, 2 * hQuarter, scalePaint);
}
canvas.rotate(5f, 2 * wQuarter, 2 * hQuarter);
}
刻度线按应有的方式绘制,但问题是文本也随画布旋转。如何在重置其旋转时保持文本位置?大部分是颠倒的或在+90 -90
这里是