Android examples for Graphics:Color Darken
Returns a darker color from a specified color by the factor.
//package com.java2s; import android.graphics.Color; public class Main { /**/*from www. j a va 2s .c o m*/ * Retuns a darker color from a specified color by the factor. * @param color * @param factor * @return */ public static int darker(int color, float factor) { int a = Color.alpha(color); int r = Color.red(color); int g = Color.green(color); int b = Color.blue(color); return Color.argb(a, Math.max((int) (r * factor), 0), Math.max((int) (g * factor), 0), Math.max((int) (b * factor), 0)); } }