Java – Gets the median color between two colors

Gets the median color between two colors… here is a solution to the problem.

Gets the median color between two colors

I

have string representations of 2 colors (e.g. “#FFFFFF” and "#0000000“) and I’m looking for a way to get both colors programmatically. The color I call the “median” is the color that intersects these two colors in the center.

I need it to draw the gradient in two steps :

  • 1 gradient from the first color to the median
  • 1 Gradient from the middle color to the second color

So it looks like a 1 gradient from the first color to the second, which I can’t do.

How can I do this?

Solution

Maybe you can try this :

new ArgbEvaluator().evaluate(0.5, 0xffffff, 0x000000);

More information:
http://developer.android.com/reference/android/animation/ArgbEvaluator.html :

Related Problems and Solutions