Android examples for Graphics:Change Color
change Status Bar Color
import android.app.Activity; import android.graphics.Color; import android.os.Build; import android.view.WindowManager; public class Main { public static void changeStatusBarColor(Activity activity, int color) { if (color == 0) return;// www . j a v a2s . c o m if (isLollipopOrHigher()) { float cl = 0.9f; float[] hsv = new float[3]; Color.colorToHSV(color, hsv); hsv[2] *= cl; int primaryDark = Color.HSVToColor(hsv); activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); activity.getWindow().setStatusBarColor(primaryDark); } } public static boolean isLollipopOrHigher() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; } }