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)
- Firmata protocol with Raspberry Pi and Arduino - September 13, 2017
- IOT:Power outlet controlled from internet using WeMOS - August 9, 2017
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017