如何旋转使用canvas.drawTextOnPath()绘制的文本?

问题描述 投票:0回答:1

我正在使用drawTextOnPath()创建弯曲的文本,如下面的给定图片,但我不知道如何旋转文本?

我想要的在下面用箭头和圆圈突出显示的图片中。

enter image description here

我已经能够实现的目标在下面

enter image description here

所以我只想旋转这些文本?

android canvas android-canvas android-custom-view
1个回答
0
投票
float radius = 300; float cx = getWidth() / 2; //Center of the circle float cy = getHeight() / 2; //Center of the circle for (int degree = 0; degree < 360; degree += 30) { canvas.save(); canvas.translate(cx, cy); canvas.rotate(degree); canvas.rotate(-degree, radius, 0); canvas.drawText("" + degree, radius, 0, textPaint); canvas.restore(); }

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.