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.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With