In this case of two colors, to fix the problem we can draw a whole circle of a first color, and then draw wedges of the second color on it. Like this:
int wedgeNum = 10;
float wedgeSweepAngle = 360f / wedgeNum;
// draw a round gray background
canvas.drawCircle(bounds.centerX(), bounds.centerY(), bounds.width() / 2f, paints[1]);
// draw only green wedges
for (int i = 0; i < wedgeNum; i += 2) {
canvas.drawArc(bounds, i * wedgeSweepAngle, wedgeSweepAngle, true, paints[0]);
}
In general, we can draw wedges in reverse order. Besides, start angle of all wedges will be 0, and end angle will have old value. First, we draw the last sector from 0 to 360 degrees, i.e. whole circle. Then draw wedge with number (n - 1)
from 0 to (360 - sweep angle of the last wedge) degrees. And so on.
int wedgeNum = 10;
float wedgeSweepAngle = 360f / wedgeNum;
// end angle, we will decrease this value on each iteration
float endAngle = 360f;
// start angle, always 0
final float startAngle = 0f;
// reverse order
for (int i = wedgeNum - 1; i >= 0; i--) {
// draw wedge from 0 to endAngle
canvas.drawArc(bounds, startAngle, endAngle, true, paints[i % 2]);
// calculate the next wedge's end angle
endAngle -= wedgeSweepAngle;
}
Hope it will help.