画一个弧线,在Android的一个SweepGradient [英] Draw an arc with a SweepGradient in Android
本文介绍了画一个弧线,在Android的一个SweepGradient的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可以得出使用着色器的弧线,如SweepGradient?
How can I draw an arc using a Shader such as SweepGradient?
例子我都拿漆对象:
Paint lightRed = new Paint();
lightRed.setAntiAlias(true);
lightRed.setStyle(Style.STROKE);
lightRed.setStrokeWidth(12);
lightRed.setColor(0xFFCC0000);
...
canvas.drawArc(rectf, -90, 360, false, lightRed);
别以为它的确与众不同,但我用它来绘制一个主屏幕小工具
Don't think it makes a difference, but I'm using it to draw to a homescreen widget
推荐答案
试试这个:
Shader gradient = new SweepGradient (0,getMeasuredHeight()/2, Color.RED, Color.WHITE);
lighted.setShader(gradient);
canvas.drawArc(rectf, -90, 360, false, lightRed);
您可以修改位置和颜色值。
You can modify the position and color values.
这篇关于画一个弧线,在Android的一个SweepGradient的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文