This post will let you create a simple Color picker android application which will return the HEX code from the values set by R,G, and B labeled seekbars. In this application you can not only get the HEX value of the color generated but you can also set the color as the application background. This app is created by 3 seekbars and 1 EditText and 2 buttons.
The value of the seekbars are extracted form the getProgress() method. and the obtained values from R,G, and B are converted to hex using toHexString() method and finally they are concatenated together for the HEX code of the RGB.
Lets have a glimpse on the basic concepts of the MainActivity.java
Fetching values from the Seekbars
Setting the value of the Hex Code box from the Seekbars
Changing the Background color from the Hex Code
rl.setBackgroundColor(Color.rgb(r, g, b));
/* rl is the relative layout variable which was declared on the onCreate method
Alternatively you can download the whole code here.
Found Bugs, please report us, we will be glad to fix them ! 😀
Latest posts by Bikash Panda (see all)
- RPi GPIO Programming using Arduino Web IDE - August 12, 2018
- Arduino: String to Array Conversion based on delimiter - July 20, 2018
- OpenHAB2Installation on Ubuntu Server (16.04) - May 29, 2018