Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaredrummler/colorpicker
A highly customizable color picker for Android
https://github.com/jaredrummler/colorpicker
android android-library color-picker colorpicker dialog preference
Last synced: about 1 month ago
JSON representation
A highly customizable color picker for Android
- Host: GitHub
- URL: https://github.com/jaredrummler/colorpicker
- Owner: jaredrummler
- License: apache-2.0
- Created: 2016-05-31T20:48:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-07-29T20:09:51.000Z (4 months ago)
- Last Synced: 2024-10-15T16:02:52.335Z (about 1 month ago)
- Topics: android, android-library, color-picker, colorpicker, dialog, preference
- Language: Java
- Homepage:
- Size: 3.17 MB
- Stars: 791
- Watchers: 38
- Forks: 172
- Open Issues: 39
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Color Picker
Yet another open source color picker for Android. So, why should you use this color picker? It is highly customizable and easy to use. You can simply add the `ColorPreference` to your preferences and a beautiful color picker dialog will be displayed without additional code. The color picker supports alpha and allows you to set your own presets.
The original ColorPickerView was written by [Daniel Nilsson](https://github.com/danielnilsson9/color-picker-view).
## Screenshots
![GIF](art/demo.gif)
## Usage
Add the `ColorPreference` to your preference XML:
```xml
...
```
Note: Using AndroidX's `PreferenceFragmentCompat`? Then use `com.jaredrummler.android.colorpicker.ColorPreferenceCompat`
You can add attributes to customize the `ColorPreference`:
| name | type | documentation |
|---------------------|-----------|---------------------------------------------------------------------------------------|
| cpv_dialogType | enum | "custom" to show the color picker, "preset" to show pre-defined colors |
| cpv_showAlphaSlider | boolean | Show a slider for changing the alpha of a color (adding transparency) |
| cpv_colorShape | enum | "square" or "circle" for the shape of the color preview |
| cpv_colorPresets | reference | An int-array of pre-defined colors to show in the dialog |
| cpv_dialogTitle | reference | The string resource id for the dialog title. By default the title is "Select a Color" |
| cpv_showColorShades | boolean | true to show different shades of the selected color |
| cpv_allowPresets | boolean | true to add a button to toggle to the custom color picker |
| cpv_allowCustom | boolean | true to add a button to toggle to the presets color picker |
| cpv_showDialog | boolean | true to let the ColorPreference handle showing the dialog |You can also show a `ColorPickerDialog` without using the `ColorPreference`:
```java
ColorPickerDialog.newBuilder().setColor(color).show(activity);
```All the attributes above can also be applied to the `ColorPickerDialog`. The activity that shows the dialog *must*
implement `ColorPickerDialogListener` to get a callback when a color is selected.For further doumentation about how to use the library, check the [demo](demo) app included in this project.
## Download
Download [the latest AAR](https://repo1.maven.org/maven2/com/jaredrummler/colorpicker/1.1.0/colorpicker-1.1.0.aar) or grab via Gradle:
```groovy
implementation 'com.jaredrummler:colorpicker:1.1.0'
```## License
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 athttp://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.