Create a Simple Color Picker Android App [Seekbar Support]
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.
Demo:
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
Alternatively you can download the whole code here.
Found Bugs, please report us, we will be glad to fix them ! :D
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.
Demo:
The Hex Code generated when tapped on the generate Button
The Background Color changes with corresponding value of Hex code when tapped on Set It
Lets have a glimpse on the basic concepts of the MainActivity.java
Fetching values from the Seekbars
r=sb1.getProgress(); g=sb2.getProgress(); b=sb3.getProgress();
Setting the value of the Hex Code box from the Seekbars
et.setText("#"+Integer.toHexString(r)+Integer.toHexString(g)+Integer.toHexString(b));
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 rl=(RelativeLayout)findViewById(R.id.layout1); */
Alternatively you can download the whole code here.
Found Bugs, please report us, we will be glad to fix them ! :D
Very interesting information that you have shared with us.i have personally thank you for sharing your ideas with us.
ReplyDeleteAndroid Training in Chennai
Android Training in Velachery
JAVA Training in Chennai
Python Training in Chennai
Big data training in chennai
Selenium Training in Chennai
Android Training in Chennai
Android Training in Tambaram
Most Useful blog for everyone who wants to gather a lot.
ReplyDeleteAndroid Training Institute in Chennai | Android Training Institute in anna nagar | Android Training Institute in omr | Android Training Institute in porur | Android Training Institute in tambaram | Android Training Institute in velachery