Android: draw arc within canvas api with a gradient fill color

Swapnil picture Swapnil · Jan 12, 2012 · Viewed 11.3k times · Source

I want to draw an arc using canvas using a gradient fill. How can achieve this?

Answer

Quintin Balsdon picture Quintin Balsdon · Jun 21, 2012

Hey I stole this from here: Draw an arc with a SweepGradient in Android

but it works fine, I used a LinearGradient instead.

Shader gradient = new SweepGradient (0,getMeasuredHeight()/2, Color.RED, Color.WHITE);
lightRed.setShader(gradient);
canvas.drawArc(rectf, -90, 360, false, lightRed);