Java tutorial
//package com.java2s; // Use of this source code is governed by a BSD-style license that can be import android.graphics.Color; public class Main { private static final float LIGHT_PROGRESSBAR_BACKGROUND_ALPHA = 0.5f; /** * Gets the background color for light theme progress bar. * @param toolbarColor The color of the toolbar. * @return The color of the progress bar in light theme, given the toolbar color. */ public static int getLightProgressbarBackground(int toolbarColor) { return getColorWithOverlay(Color.WHITE, toolbarColor, LIGHT_PROGRESSBAR_BACKGROUND_ALPHA); } private static int getColorWithOverlay(int baseColor, int overlayColor, float overlayAlpha) { return Color.rgb( (int) (overlayAlpha * Color.red(baseColor) + (1f - overlayAlpha) * Color.red(overlayColor)), (int) (overlayAlpha * Color.green(baseColor) + (1f - overlayAlpha) * Color.green(overlayColor)), (int) (overlayAlpha * Color.blue(baseColor) + (1f - overlayAlpha) * Color.blue(overlayColor))); } }