I have the following problem:
I have a list view, I want to assign a gradient color to item separator ( Divider) of this list view. I am using the following code:
list = (ListView) findViewById(R.id.list);
int[] colors = { 0, 0xffffff00, 0 };
list.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors));
list.setDividerHeight(4);
I looked up the color code (0xffffff00) from: http://developer.android.com/reference/android/graphics/Color.html
PROBLEM:
However this color is Yellow, what I want is golden. I am also interested to know how this works, I mean how can I define the color of my choice, so far I tried to understand from the developer site but it is not much clear.
that you wrote is the hex notation. You can think about a color as composed of 4 components. ARGB. In your example you have 0xffffff00. The first ff is the alpha component, the second ff is the red component, the third ff is green component the fourth 00 is the blue component. Change those hexadecimal values you can get your colors.
Use
int color = Color.argb(255, 255, 175, 64);
or use an iteger to hex converter
For gold you need a yellow that's more red than green, so try 0xffffc000. In decimal that would be red 255 green 192 blue 0. To really get a hold of how the RGB system works spend a while playing with the values, I don't think it's possible to get a deep understanding just by reading about it.
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