[英]How do you set the paint color to orange in Android?
In Android, I am able to set Paint Color to some colors, but for orange, I cannot.在 Android 中,我可以将 Paint Color 设置为某些颜色,但对于橙色,我不能。 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.等等。
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. Color
不是枚举,它是一个包含最常用颜色的Color
常量的类。 You can easily create new custom colors by instantiating Color
.您可以通过实例化
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:您可以通过将红色、绿色和蓝色值作为 0 到 255 之间的浮点数传递来创建
Color
的新实例。这是一个简单的示例:
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:如果您制作的颜色只会比原始颜色更亮或更暗,您可以使用
brighter
或darker
方法,如下所示:
Color brigherColor = mycolor.brighter();
or this:或这个:
Color darkerColor = mycolor.darker();
For more information, see the official documentation for Color
.有关更多信息,请参阅
Color
的 官方文档。
I would write this:我会这样写:
int ORANGE= 0xffa500;
p.setColor(ORANGE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.