What 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 my question is: this function below is the function I'm talking about, and has a parameter int[] colors

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

What values ​​can I put in the colors of int []? I know that the following value works.

  • 0xAARRGGBB

But my problem is that I recalculate the hash values ​​in my program, but they end as String, but it should end as an integer.

And it is not possible to convert a hash value, for example: String 0x34F323 to Int 0x34F323. When I recalculated the hash value and get:

String: #125BD7

And I use Integer.Decode ("# 125BD7"); The output will consist of seven numbers. But this does not work in the GradientDrawable method with the int [] parameter. Because all I get is a black background.

Can someone help me? What values ​​can I use in the GradientDrawable method?

+5
source share
1 answer

Use Color.parseColor("#45F434");. Returns an integer. But the color code should not be G. Only Hex ( 0-F) values ​​are allowed .

Take a look at the Color link . Color can be dangerous. Take a look at the constants.

+2
source

All Articles