change Color Alpha - Android Graphics

Android examples for Graphics:Color Alpha

Description

change Color Alpha

Demo Code


//package com.java2s;
import android.graphics.Color;

public class Main {
    public static int changeAlpha(final int color, final int amount) {
        int a = Color.alpha(color);
        final int r = Color.red(color);
        final int g = Color.green(color);
        final int b = Color.blue(color);

        a += amount;/*from  w  w  w. j a  v a 2  s .  c o m*/
        if (a > 255) {
            a = 255;
        }
        if (a < 0) {
            a = 0;
        }
        return Color.argb(a, r, g, b);
    }
}

Related Tutorials