Using the setColor method on the Paint object, we can pass in a Color object. The Color class defines a series of colors represented as 32bit integers as constants:

For the complete list, you can refer to the online reference for the Color class at

Paint paint = new Paint(); paint.setColor(Color.GREEN);

We can also construct a specific color by calling the static method Color.argb, passing in a value between 0 and 255 for alpha, red, green, and blue. This method returns a 32bit integer representing that color that we then pass to setColor.

int myColor = Color.argb(255,128,64,32);


We can actually skip the color creation step completely if we are defining the exact values:

Paint paint = new Paint(); paint.setARGB(255,128,64,32);

Was this article helpful?

0 0

Post a comment