- Simple dialog builder
- RGB & HSV color models, with optional alpha channel
- Dark theme support
- Sliders with gradient background
- Switch color models in runtime
Kotlin DSL:
implementation("io.github.vadiole:colorpicker:1.0.4")
Groove:
implementation 'io.github.vadiole:colorpicker:1.0.4'
// Create dialog
val colorPicker: ColorPickerDialog = ColorPickerDialog.Builder()
// Set initial (default) color
.setInitialColor(currentColor)
// Set Color Model, can be ARGB, RGB, AHSV or HSV
.setColorModel(ColorModel.HSV)
// Set is user be able to switch color model
.setColorModelSwitchEnabled(true)
// Set your localized string resource for OK button
.setButtonOkText(android.R.string.ok)
// Set your localized string resource for Cancel button
.setButtonCancelText(android.R.string.cancel)
// Callback for picked color (required)
.onColorSelected { color: Int ->
// Use color
}
// Create dialog
.create()
// Show dialog from Activity
colorPicker.show(supportFragmentManager, "color_picker")
// Show dialog from Fragment
colorPicker.show(childFragmentManager, "color_picker")