colorpicker
colorpicker copied to clipboard
LightnessSlider not updated when setInitialColor() called
By setting an initial value with setInitialColor(int, boolean)
, the lightness slider is not updating. It stays at position 0
, whereas the alpha slider is updated correctly.
For example, if I do this:
int mColor = -154296; // yellow, full light, full opacity
colorPickerView.setInitialColor(mColor, false);
I got the below result on the left:
However, if I select another color directly in the wheel, the sliders are both updating properly, like the right screenshot above (full light, full opacity).
context: used in fragment with widgets in xml (no dialog)
Weirdly I have to set (again) the lightness color in a runnable as:
colorPickerView.setInitialColor(mColor, false);
// assuming that mBarLightness is the LightnessSlider view
mBarLightness.post(new Runnable() {
@Override
public void run() {
mBarLightness.setColor(mColor);
}
});
I said again because in the ColorPickerVIew
you already did it in onLayout(...)
which call setLightnessSlider(...)
and set the color into it... that's why it seems weird.
I have met same issue