简体   繁体   中英

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.

I have to create an application that manages RGB parameters of a button in order to change its color.

Layout consist of 3 seekbars, the first of them manages Red parameters, the second one Green parameters and the third one Blue parameters. Obviously there is a button, too.

In which way can I "connect" these seekbars to the button in order to change its RGB values? Are there specific functions to manage RGB parameters of a button by using some SeekBars for everyone of these parameters?

Have each seekbar give you a String hex value between 0 and FF, then assemble those values and parse the color:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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