Open juliswer opened 1 year ago
Hey @juliswer, have you ever tried the way below?
ColorPickerView colorPickerView = builder.getColorPickerView();
colorPickerView.setFlagView(new CustomFlag(this, R.layout.layout_flag)); // sets a custom flagView
colorPickerView. setInitialColor(..)
hey @skydoves. Yes, i did. The issue is that the code you provided me with is referred to a ColorPickerView, but I'm using a ColorPickerDialog.
This ColorPickerDIalog is not allowing the same methods (setInitialColor & setFlagView) than the ColorPickerView.
this is my implementation:
val colorPickerDialog = ColorPickerDialog.Builder(context, R.style.ColorPickerDialog)
.setTitle("Pick a Color")
.setPreferenceName("ColorPickerDialog")
.setPositiveButton("Apply",
ColorEnvelopeListener { envelope, _ ->
// beauty color
})
.setNegativeButton(
"Cancel"
) { dialogInterface, _ -> dialogInterface.dismiss() }
.setNeutralButton("Delete color") { _, _ -> deleteColor(colorPosition) }
.attachAlphaSlideBar(false)
.attachBrightnessSlideBar(true)
.setBottomSpace(12)
.show()
@juliswer You can extend the class and use something like this
public Builder setDefaultColor(int code) {
if (getColorPickerView() != null) {
getColorPickerView().setInitialColor(code);
}
return this;
}
Overview
Bug: As in the ColorPickerView component, I'd expect to have the same options on the ColorPickerDialog. What do I mean with the same options? Im talking about the method .setInitialColor() and the ability to set a flagView as well.
Do you have some solution to set an initial color in a ColorPickerDialog?