Eclipse Color-Mix is an advanced library to mix/select color by mixing RGBA colors.
-
Download this project and import as Android application in eclipse ADT.
-
Add ColorMixer library to your project.
-
Now in your project:
i. Implement the ColorSelector.ColorControl interface in your class. Implement the unimplemented methods. This will override two methods public void onCancelled() and public void onColorSelected(int color). Actually these methods are the listener methods.
-
Create an instance of the ColorSelector class and innitialize it. The innitialization takes two mandatory parameters, the context and the ColorControl object. Alternatively you can pass one more parameter as int. This one is the theme for the Color dialog.
ColorSelector cs = new ColorSelector(Context context, ColorControl colorControl, int theme);
ColorSelector cs = new ColorSelector(this, this, 4);
- Now call the show() method on the object of ColorSelector class
cs.show();
The ColorSelector class contains one interface named ColorControl. This ColorControl interface contains following methods:
The method gets called when the user cancels the ColorSelector dialog. Can be used to free resources.
The method gets called when the user selects a color. The parameter 'int color' contains the color selected by the user. This color can now be used in your application.
The ColorSelector class contains several methods to control the look, feel and features of the color mixer dialog. Here are the methods:
Takes a pareameter as a color of Color class or an integer color and sets the innitial color value to it. The method must be called before the show() method.
Takes 4 pareameters as integers and sets the innitial color value to it. The values of these integers could be 0-255 and are alpha, red, green and blue respectively. The method must be called before the show() method.
Same as setARGBColor method without an alpha channel.
Takes a boolean parameter to specify whether it supports alpha channel.
Takes a boolean parameter to specify whether color preview should be displayed.
Takes a boolean parameter to specify whether color LEDs should be displayed.