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.
- Color Picker View
- Color Picker Dialog with Recent Color Option
- Material Color Picker Alert Dialog
- Material Color Picker BottomSheet Dialog
Color Picker | Material Color Picker |
---|---|
-
Gradle dependency:
implementation 'com.github.dhaval2404:colorpicker:1.0'
-
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()
-
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()
-
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>
- Library - Android Lollipop 5.0+ (API 21)
- Sample - Android Lollipop 5.0+ (API 21)
- Initial Build
- ColorPicker https://github.com/duanhong169/ColorPicker
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.
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.