问题描述
我有以下自定义视图:
这是我通过使用 Canvas 的 drawArc()
方法实现的.但是,使用此 drawArc()
方法,我无法限制圆弧的内半径.
This I have achieved by using the Canvas' drawArc()
method. However, with this drawArc()
method I cannot limit the arc's inner radius.
我想要的是这样的:
只剩下一个外环.
我需要的是一个 drawArc()
函数,我可以在其中设置圆弧的内半径.有人知道怎么做吗?
What I need is an drawArc()
function where I can set the inner radius of the arc. Anyone an idea how to do that?
(顺便说一句,对内部区域进行覆盖不起作用,因为它需要是透明的.在绘制红色和蓝色锥体后,使用 Color.TRANSPARENT
绘制内圆并不会删除旧的颜色.它只是在上面再放一层,它是透明的,通过它我仍然可以看到红色和蓝色)
(BTW, overpainting the inner area doesn't work, because it needs to be transparent. Painting an inner circle with Color.TRANSPARENT
after painting the red and blue cones doesn't remove the old color. It just puts another layer on top, which is transparent and through which I can still see the red and blue)
推荐答案
您可以使用名为Clear"的 PorterDuff xfermode 绘制内部区域.这将擦除像素.
You can paint over the inner area using the PorterDuff xfermode called "Clear." This will erase pixels.
这篇关于Android:寻找带有内部 & 的 drawArc() 方法外半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!