public static String getRandomColorCode() {
String r, g, b;
Random random = new Random();
r = Integer.toHexString(random.nextInt(256)).toUpperCase();
g = Integer.toHexString(random.nextInt(256)).toUpperCase();
b = Integer.toHexString(random.nextInt(256)).toUpperCase();
r = r.length() == 1 ? "0" + r : r;
g = g.length() == 1 ? "0" + g : g;
b = b.length() == 1 ? "0" + b : b;
return "#"+r+g+b;
}
随机获取十六进制颜色代码
猜你喜欢
转载自blog.csdn.net/qq_41841482/article/details/114483060
今日推荐
周排行