I have the following onDraw
:
public void onDraw(Canvas canvas) {
paint = new Paint();
paint.setColor(Color.RED);
canvas.drawRect(rectangulo,paint);
}
I would like to know how to implement so that it was not just Color.RED
, but random colors.
Something like an array with several colors and the color set calls it?
This is my code:
private static final int[] colores = {Color.GREEN,Color.BLUE,Color.RED};
In the constructor:
r = new Random();
num = r.nextInt(3);
and the Ondraw:
public void onDraw(Canvas canvas) {
paint = new Paint();
paint.setColor(colores[num]);
canvas.drawRect(rectangulo,paint);
}