In Android, I am able to set Paint Color to some colors, but for orange, I cannot. Does anyone know if there is an option to set Paint Color to Orange?
Here are some examples of setting Paint Color to other colors beside Orange:
p.setColor(Color.YELLOW);
p.setColor(Color.BLACK);
p.setColor(Color.MAGENTA);
etc.
The orange color has a hex value #FFA500
or Color.rgb(255, 165, 0)
so
p.setColor(Color.rgb(255, 165, 0));
or
p.setColor(0xffa500);
see this for more options.
You may create your own orange color, like this:
int orange = Color.rgb(255, 165, 0);
p.setColor(orange);
Hope it helps.
Color
is not an enum, it's a class that contains Color
constants for the most commonly used colors. You can easily create new custom colors by instantiating Color
. You can create a new instance of Color
by passing the red, green, and blue values as floats between 0 and 255. Here's a simple example:
Color mycolor = new Color(0, 0, 255);
If the color you're making will simply be brighter or darker than the original color, you can use the brighter
or darker
methods, like this:
Color brigherColor = mycolor.brighter();
or this:
Color darkerColor = mycolor.darker();
For more information, see the official documentation for Color
.
I would write this:
int ORANGE= 0xffa500;
p.setColor(ORANGE);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.