I'm trying draw a custom view which has an Arc which will be filled with gradient of 4 colors and I choose SweepGradient to be suitable for this and when I tried it works fine for two colors and even if add more colors I'm not able to get the other two colors. I tried different combinations of positions as well nothing seem to work.
int colorRes[] = {R.color.yellow, R.color.green,R.color.oragne, R.color.red};
float stops[] = {0,0.3f,0.6f,1};
int colors[] = new int[colorRes.length];
for(int i=0;i<colorRes.length;i++){
colors[i]= context.getResources().getColor(colorRes[i]);
}
Shader gradient = new SweepGradient (wdith/2,height/2, colors, stops));
lighted.setShader(gradient);
canvas.drawArc(rectf, 130, 280, false, lightRed);