Android UI How to - Get Random Color








Question

We would like to know how to get Random Color.

Answer


import android.graphics.Color;

public class Main {
  public static int randomColor(){
      return Color.argb(127, ((Long)Math.round(Math.random() * 255)).intValue(), ((Long)Math.round(Math.random() * 255)).intValue(),((Long)Math.round(Math.random() * 255)).intValue() );
  }
}