Skip to content

SimpleColorDialog

Philipp Niedermayer edited this page Jun 12, 2021 · 5 revisions

Color palette picker

extends CustomListDialog, Full API reference

A Dialog that can be used to choose a color from a pallet. Also allows for custom colors using the ColorWheelDialog

Example

SimpleColorDialog.build()
                 .title(R.string.pick_a_color)
                 .colorPreset(color)
                 .allowCustom(true)
                 .show(this, COLOR_DIALOG);

Available customizations

  • Color pallet
    .colors(Context context, @ArrayRes int colorArrayRes)
    .colors(@ColorInt int[] colors)
    Predefined pallets to be used as colorArrayRes:
    @ArrayRes int SimpleColorDialog.MATERIAL_COLOR_PALLET (default if unspecified)
    @ArrayRes int SimpleColorDialog.MATERIAL_COLOR_PALLET_LIGHT
    @ArrayRes int SimpleColorDialog.MATERIAL_COLOR_PALLET_DARK
    @ArrayRes int SimpleColorDialog.BEIGE_COLOR_PALLET
    @ArrayRes int SimpleColorDialog.COLORFUL_COLOR_PALLET
  • Initial selected color
    .colorPreset(@ColorInt int color)
  • Allow custom
    .allowCustom(boolean allow) .setupColorWheel* various methods to configure the color wheel dialog shown when the user clicks the "custom" palette icon, see javadoc
  • Style
    .showOutline(@ColorInt int color)
  • Multi select
    .choiceMode(SimpleColorDialog.MULTI_CHOICE) (derived from CustomListDialog)

Receiving results

See Receiving results from SimpleDialog. The extras Bundle returned will contain the following keys:

@ColorInt int color = extras.getInt(SimpleColorDialog.COLOR);  // The color chosen 
int[] colors = extras.getIntArray(SimpleColorDialog.COLORS);   // the colors chosen if multi select was enabled

Clone this wiki locally