My favorites | Sign in
Project Home Wiki Issues Source
Project Information
Members

Android Color Picker

aka AmbilWarna library ("Pick a Color" in Indonesian)

This is a small library for your application to enable the users to select an arbitrary color. It is currently used in the free Bible applications for Android (http://androidbible.blogspot.com). It is also used by the >250,000 downloads app DigiClock Widget.

For example, your application has a feature to customize the color of some background, text, or maybe for a painting application where the user should be able to select different color for painting or filling.

Codes are available at http://code.google.com/p/yuku-android-util/source/browse/#git%2FAmbilWarna

Screenshot:

This is an Android Library Project where you can include it into your main project.

How to use

Create a color picker dialog by calling the following constructor, and then show it.

AmbilWarnaDialog(Context context, int color, OnAmbilWarnaListener listener)

as follows:

// initialColor is the initially-selected color to be shown in the rectangle on the left of the arrow.
// for example, 0xff000000 is black, 0xff0000ff is blue. Please be aware of the initial 0xff which is the alpha.
AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, initialColor, new OnAmbilWarnaListener() {
	@Override
	public void onOk(AmbilWarnaDialog dialog, int color) {
		// color is the color selected by the user.
	}
		
	@Override
	public void onCancel(AmbilWarnaDialog dialog) {
		// cancel was selected by the user
	}
});

dialog.show();

You need to link against Android 3.0 or higher since there is an XML attribute layerType in use. This doesn't mean you can use this only for applications requiring Android 3.0 to operate. It works even in Android 1.6. You just need to select Android 3.0 (API level 11) on the project settings.

Contributors

Pascal Cans (noobs.com)

See also other projects for Android:

Powered by Google Project Hosting