0

我正在创建一个显示设备倾斜角度的应用程序,并且弧形扫描显示了对向的角度。我可以使用 ShapeDrawable 创建圆弧,但无法更改此圆弧的半径。

在此处输入图像描述

以下是我使用的代码:

circularArc = new ShapeDrawable(new ArcShape(-90, angleValue));
circularArc.getPaint().setColor(Color.GRAY);
circularArc.setIntrinsicHeight(100);
circularArc.setIntrinsicWidth(100);
compass_image.setBackground(circularArc);

setIntrinsicWidth 和 Height 在这里似乎是多余的,因为它不会改变弧的半径。请提出一些建议,以便我可以将其覆盖为半幅图像,而不是覆盖完整图像的弧。

编辑:按照@pskink 的建议尝试了Inset drawable,我很有趣的代码:

circularArc = new ShapeDrawable(new ArcShape(-90, angleValue));
            circularArc.getPaint().setColor(Color.GRAY);
            InsetDrawable insetDrawable = new InsetDrawable(circularArc, 50,100,200,300);

            compass_image.setBackground(insetDrawable);

在此处输入图像描述

如您所见,它只是移动整个图像。我想要的是将圆弧移动到下图中的一半:

在此处输入图像描述

4

0 回答 0