As a rule, to obtain a bright color, one of the RGB values is required that is greater than 128, so you can get 3 random values and check that one of them must be greater than 128. The higher the value, the brighter it will be.
You can check that the average value is greater than 128, it can bring a good result.
public int getRandomColor() { Random rndm = new Random(); int r = rndm.nextInt(256); int g = rndm.nextInt(256); int b = rndm.nextInt(256); int adjust = 0; if( (r + g + b)/3 < 128) int adjust = (128 - (r + g + b)/3)/3; r += adjust; g += adjust; b += adjust; return Color.argb(255, r, g, b); }
source share