0

http://www.colorschemer.com/online.html

in the left side of above url

  1. one box is there which displays color and below to that R G B input fields are there on filling a value and clicking Set RGB ,we can see the new color

is there any api for doing the same in Andorid

Swetha reddy
  • 61
  • 1
  • 11

3 Answers3

4

You can use the Color class which is an default android class.

int rgb = Color.rgb(red, blue, green)

it has static method rgb() which takes the red, blue and green colors and returns the mixed color.

Susanth S
  • 66
  • 2
0

I would use this small snip it:

int r = (color >> 16) & 0xFF;
int g = (color >> 8)  & 0xFF;
int b =  color        & 0xFF;

This takes your color and converts it to the channels. The >> operator does bit shifting which is equal to a division of 256 or 65536. That is by the way the same thing what the android.graphics.Color class does internally.

rekire
  • 46,262
  • 29
  • 163
  • 256
0

You can use the android.graphics.Color class. It has a red(int), green(int) and blue(int) method (among some others useful methods).

Gaëtan
  • 11,042
  • 5
  • 32
  • 45