Android examples for Graphics:Random Color
random Basic Color from color array
//package com.java2s; import android.graphics.Color; import java.util.Random; public class Main { public static final int[] BASIC_RANDOM_COLORS = new int[] { Color.parseColor("#007a87"), Color.parseColor("#7b0051"), Color.parseColor("#1b67ac"), Color.parseColor("#638962") }; public static int randomBasicColorIndex(int indexBefore) { int resultIndex; Random rand = new Random(); resultIndex = indexBefore/* www . j ava 2s .c om*/ + rand.nextInt(BASIC_RANDOM_COLORS.length - 2) + 1; return resultIndex % BASIC_RANDOM_COLORS.length; } }