开发者

Draw an arc with a SweepGradient in Android

How can I draw an arc using a Shader开发者_如何学编程 such as SweepGradient?

The examples I have all take a Paint object:

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


Try this:

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜