Skip to content

dmfs/color-picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

95eea66 · Jun 5, 2019

History

44 Commits
Jun 5, 2019
Jun 5, 2019
Jun 5, 2019
Jan 21, 2017
Apr 22, 2015
May 9, 2014
May 9, 2014
Nov 13, 2018
Jun 5, 2019
Jan 21, 2017
Apr 22, 2015
Nov 13, 2018

Repository files navigation

color-picker

Just another color picker for Android

This is a nice and simple color picker for Android. It allows to show any number of different palettes with any (reasonable) number of colors. Palettes can be stored in an array or generated on the fly.

Requirements

Example code

To show the dialog, just get an instance, add a number of palettes and call the show method.

		ColorPickerDialogFragment d = new ColorPickerDialogFragment();

		// set the palettes
		d.setPalettes(new AbstractPalette[]
		{
			ArrayPalette.fromResources(this, "basecolors", R.string.base_palette_name, R.array.base_palette_colors, R.array.base_palette_color_names),
			new FactoryPalette("rainbow", "Rainbow", ColorFactory.RAINBOW, 16)
		});
		
		d.show(getSupportFragmentManager(), tag);

The calling activity or fragment should implement ColorPickerDialogFragment.ColorDialogResultListener to get the result like:

		@Override
		public void onColorChanged(int color, String colorName, String paletteName)
		{
			// do something with color
		}

		@Override
		public void onColorDialogCancelled()
		{
			// handle cancelled color picker dialog
		}

Screen shots

TODO

  • fix landscape mode on smaller screens
  • fix selected/focused backgrounds
  • allow to customize color shapes
  • allow to preselect a specific color
  • add support for other fragment types, like hex input or color wheels

License

Copyright (c) dmfs GmbH 2018, licensed under Apache 2 (see LICENSE).