简体   繁体   English

你如何在 Android 中将油漆颜色设置为橙色?

[英]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.等等。

The orange color has a hex value #FFA500 or Color.rgb(255, 165, 0) so橙色具有十六进制值#FFA500Color.rgb(255, 165, 0)所以

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. 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:如果您制作的颜色只会比原始颜色更亮或更暗,您可以使用brighterdarker方法,如下所示:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM