/ColorPicker

🎨 Color Picker Library for Android

Primary LanguageKotlinApache License 2.0Apache-2.0

🎨Color Picker Library for Android

Download Releases API Language PRWelcome Twitter

Built with ❤︎ by Dhaval Patel and contributors

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

💻Usage

  1. Gradle dependency:

    implementation 'com.github.dhaval2404:colorpicker:1.2.1'
  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 change the color or Positive and Negative Button Text Color. Add Following parameters in your colors.xml file.

    <resources>
        <!-- Here you can add color of your choice  -->
        <color name="positiveButtonTextColor">@color/colorAccent</color>
        <color name="negativeButtonTextColor">@color/colorAccent</color>
        <color name="bottomSheetDividerColor">#F5F5F5</color>
    </resources>
  • 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)

✔️Changelog

Version: 1.2

  • Added Dark mode support & German translation #4

Version: 1.1

  • Added option to change positive and negative button text color #2

Version: 1.0

  • Initial Build

📃 Libraries Used

Let us know!

We'll be really happy if you sent us links to your projects where you use our component. Just send an email to dhavalpatel244@gmail.com And do let us know if you have any questions or suggestion regarding the library.

License

Copyright 2020, Dhaval Patel

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.