软件简介
ColorPicker
一款标准的Android颜色选择器,使用HSV和透明度选择颜色。
Gradle
dependencies {
implementation 'com.github.duanhong169:colorpicker:${latestVersion}'
...
}
${latestVersion}请替换为当前最新版本号,见
releases.
Usage
使用 ColorPickerPopup
new ColorPickerPopup.Builder(this)
.initialColor(Color.RED) // Set initial color
.enableAlpha(true) // Enable alpha slider or not
.okTitle("Choose")
.cancelTitle("Cancel")
.showIndicator(true)
.showValue(true)
.build()
.show(v, new ColorPickerPopup.ColorPickerObserver() {
@Override
public void onColorPicked(int color) {
v.setBackgroundColor(color);
}
@Override
public void onColor(int color, boolean fromUser) {
}
});
使用 ColorPickerView
执行 ColorObserver 并订阅 ColorPickerView以从 ColorPickerView 接收颜色更新:
colorPickerView.subscribe((color, fromUser) -> {
// use the color
});
设置初始颜色:
colorPickerView.setInitialColor(0x7F313C93);
重置初始颜色:
colorPickerView.reset();
更详细的使用方法请参见示例。