Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which color values can be used for GradientDrawable

In my application i am trying to draw a gradientBackground from code. My goal is to make this background dynamic.

Now is my question this function below is the function i am talking about, and has a parameter int[] colors

GradientDrawable(GradientDrawable.Orientation orientation, int[] colors);

Which values can i put in int[] colors? I know the following value works.

  • 0xAARRGGBB

But my problem is, i recalculate hash values in my program but they end as a String, but it has to end as an Integer.

And it isn't possible to convert a hash value like: String 0x34F323 to Int 0x34F323. When i recalculated the hash value and get:

String: #125BD7

And i use Integer.Decode("#125BD7"); The output will be a value of seven numbers. But this doesn't work in the method of GradientDrawable at the int[] parameter. Because all i get is a black background.

Can someone help me with this? Which values can i use in the GradientDrawable method?

like image 555
Dion Segijn Avatar asked Nov 04 '22 03:11

Dion Segijn


1 Answers

Use Color.parseColor("#45F434");. Which returns integer. But there should be no G in you color code. Only Hex values are acceptable (0-F).

Take a look at the Color class reference. Color can be negetive. Take a look at the constants.

like image 58
Shaiful Avatar answered Nov 10 '22 17:11

Shaiful