generate Random Color by masking int value - Android Graphics

Android examples for Graphics:Color Value

Description

generate Random Color by masking int value

Demo Code


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

public class Main {
    public static int generateRandomColor() {
        int randomColor = Color.argb(0xFF, getRandomNum(), getRandomNum(),
                getRandomNum());/*from  w w  w . j  a  v  a2  s . c o  m*/
        return randomColor;
    }

    private static int getRandomNum() {
        return (int) (Math.random() * 0xFF);
    }
}

Related Tutorials