diff --git a/library/src/main/java/com/jaredrummler/android/colorpicker/ColorPickerView.java b/library/src/main/java/com/jaredrummler/android/colorpicker/ColorPickerView.java index 2190e00..a09e324 100644 --- a/library/src/main/java/com/jaredrummler/android/colorpicker/ColorPickerView.java +++ b/library/src/main/java/com/jaredrummler/android/colorpicker/ColorPickerView.java @@ -135,7 +135,7 @@ public class ColorPickerView extends View { * Trackers can extend outside slightly, * due to the required padding we have set. */ - private Rect drawingRect; + private Rect drawingRect=new Rect(); private Rect satValRect; private Rect hueRect; @@ -729,7 +729,7 @@ private int getPreferredHeight() { return Math.max(super.getPaddingRight(), mRequiredPadding); } - @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { + /*@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); drawingRect = new Rect(); @@ -747,6 +747,33 @@ private int getPreferredHeight() { satValBackgroundCache = null; hueBackgroundCache = null; + setUpSatValRect(); + setUpHueRect(); + setUpAlphaRect(); + }*/ + + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + + int w=getWidth(); + int h=getHeight(); + +// drawingRect = new Rect(); + drawingRect.left = getPaddingLeft(); + drawingRect.right = w - getPaddingRight(); + drawingRect.top = getPaddingTop(); + drawingRect.bottom = h - getPaddingBottom(); + + //The need to be recreated because they depend on the size of the view. + valShader = null; + satShader = null; + alphaShader = null; + + // Clear those bitmap caches since the size may have changed. + satValBackgroundCache = null; + hueBackgroundCache = null; + setUpSatValRect(); setUpHueRect(); setUpAlphaRect(); @@ -878,6 +905,10 @@ public void setAlphaSliderVisible(boolean visible) { } } + public boolean getAlphaSliderVisible(){ + return showAlphaPanel; + } + /** * Get color of the tracker slider on the hue and alpha panel. *