/ Color

Color Picker Library for Android

Color Picker Library for Android

ColorPicker

Yet another Color Picker Library for Android. It is highly customizable and easy to use. Pick the color from wheel or select Material Colors from dialog. The original ColorPickerView was written by Hong Duan.

Features:

  • Color Picker View
  • Color Picker Dialog with Recent Color Option
  • Material Color Picker Alert Dialog
  • Material Color Picker BottomSheet Dialog

Preview

Color Picker Material Color Picker
colorpicker_demo materialcolorpicker_demo

Usage

  1. Gradle dependency:

    implementation 'com.github.dhaval2404:colorpicker:1.0'
    
  2. The ColorPicker configuration is created using the builder pattern.

    ColorPickerDialog
        .Builder(activity)        			// Pass Activity Instance
        .setColorShape(ColorShape.SQAURE)   // Default ColorShape.CIRCLE
        .setDefaultColor(mColor)        	// Pass Default Color
        .setColorListener { color, colorHex ->
        	// Handle Color Selection
        }
        .show()
    
  3. The MaterialColorPicker configuration is created using the builder pattern.

    MaterialColorPickerDialog
        .Builder(activity)        				// Pass Activity Instance
        .setColorShape(ColorShape.SQAURE)   	// Default ColorShape.CIRCLE
        .setColorSwatch(ColorSwatch._300)   	// Default ColorSwatch._500
        .setDefaultColor(mMaterialColorSquare) 	// Pass Default Color
        .setColorListener { color, colorHex ->
       		// Handle Color Selection
        }
        .show()
    

Customization

  • You can change title of the Dialog

    MaterialColorPickerDialog
      .Builder(activity)        			// Pass Activity Instance
      .setTitle("Pick Theme")               // Change Dialog Title
      .setColorListener { color, colorHex ->
          // Handle Color Selection
      }
      .show()
    
  • You can provide predefine colors for the MaterialColorPicker

     MaterialColorPickerDialog
         .Builder(activity)        			// Pass Activity Instance
         .setColors(							// Pass Predefined Hex Color
             arrayListOf(
             "#f6e58d", "#ffbe76", "#ff7979", "#badc58", "#dff9fb",
             "#7ed6df", "#e056fd", "#686de0", "#30336b", "#95afc0"
             )
         )
         .setColorListener { color, colorHex ->
             // Handle Color Selection
         }
         .show()
    

    or

    MaterialColorPickerDialog
        .Builder(activity)        			// Pass Activity Instance
        .setColorRes(resources.getIntArray(R.array.themeColors).toList()) // Pass Predefined Hex Color
        .setColorListener { color, colorHex ->
            // Handle Color Selection
        }
        .show()
    

    Where R.array.themeColors is defined as below

    <array name="themeColors">
      <item>@color/green_500</item>
      <item>@color/blue_500</item>
      <item>@color/red_500</item>
      <item>@color/grey_500</item>
      <item>@color/orange_500</item>
    </array>
    

Compatibility

  • Library - Android Lollipop 5.0+ (API 21)
  • Sample - Android Lollipop 5.0+ (API 21)

GitHub