Change the color to new alpha - Android Graphics

Android examples for Graphics:Color Alpha

Description

Change the color to new alpha

Demo Code

//package com.java2s;

public class Main {
    /**/*from w  w w .j a  v a2  s.  c om*/
     * Change the color to new alpha
     *
     * @param color Color
     * @param alpha New alpha
     * @return New alpha color
     */
    public static int changeColorAlpha(int color, int alpha) {
        int r = (color >> 16) & 0xFF;
        int g = (color >> 8) & 0xFF;
        int b = color & 0xFF;
        return alpha << 24 | r << 16 | g << 8 | b;
    }
}

Related Tutorials