set New color Alpha between 0 and 255 - Android Graphics

Android examples for Graphics:Color Alpha

Description

set New color Alpha between 0 and 255

Demo Code


//package com.java2s;

public class Main {
    public static int setNewAlpha0to255(int color, float alpha) {
        return setAlpha0to1(color, alpha / 255);
    }//from  w  w w. j  ava2 s.  c om

    public static int setAlpha0to1(int color, float alpha) {
        return color & 0x00FFFFFF | Math.round(0xFF * alpha) << 24;
    }
}

Related Tutorials