简体   繁体   English

使用SeekBars管理按钮的RGB参数

[英]Manage RGB parameters of a Button using SeekBars

I'm a novice programmer and I'm working on one of the my first projects on Android Studio for a school work. 我是一名新手程序员,正在从事我在Android Studio上用于学校作业的第一个项目之一。

I have to create an application that manages RGB parameters of a button in order to change its color. 我必须创建一个应用程序来管理按钮的RGB参数,以更改其颜色。

Layout consist of 3 seekbars, the first of them manages Red parameters, the second one Green parameters and the third one Blue parameters. 布局由3个搜索栏组成,其中第一个管理红色参数,第二个管理绿色参数,第三个管理蓝色参数。 Obviously there is a button, too. 显然也有一个按钮。

In which way can I "connect" these seekbars to the button in order to change its RGB values? 我可以通过哪种方式将这些搜索栏“连接”到按钮以更改其RGB值? Are there specific functions to manage RGB parameters of a button by using some SeekBars for everyone of these parameters? 是否有通过对这些参数中的每个参数使用一些SeekBar来管理按钮的RGB参数的特定功能?

Have each seekbar give you a String hex value between 0 and FF, then assemble those values and parse the color: 让每个搜寻栏为您提供介于0和FF之间的String十六进制值,然后组合这些值并解析颜色:

myColor = "#" + redSeekBarValue + greenSeekBarValue + blueSeekBarValue
yourButtonHere.setBackgroundColor(Color.parseColor(myColor));

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

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