简体   繁体   English

制作Android应用程序(随机颜色)

[英]Make Android App (Random Colors)

What I need to do is an application that when you click on the screen it will just show random colours on the screen; 我需要做的是一个应用程序,当你点击屏幕时,它只会在屏幕上显示随机颜色; press the screen again and you will get other random colours (colours that are not only Red, Blue, Green). 再次按下屏幕,您将获得其他颜色(颜色不仅是红色,蓝色,绿色)。

If you need only bright, saturated colors, use Color.HSVToColor() instead of setting R, G and B components directrly: 如果只需要明亮饱和的颜色,请使用Color.HSVToColor()而不是直接设置R,G和B组件:

float[] hsvColor = {0, 1, 1};
// randomly generate only hue component,
// leaving saturation and brightness maximum possible
hsvColor[0] = new Random().nextFloat() * 360;
view.setBackgroundColor(Color.HSVToColor(hsvColor));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM