diff --git a/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java b/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java index 0ab2246..e0a81ca 100644 --- a/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java +++ b/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java @@ -1060,17 +1060,23 @@ public void setBackgroundColor(int offColor, int onColor) { } public void setThumbColor(int thumbColor, int thumbCheckedColor, int thumbPressedColor, int thumbUnEnabledColor) { - this.thumbColor = thumbColor; - this.thumbPressedColor = thumbPressedColor; - this.thumbCheckedColor = thumbCheckedColor; - this.thumbUnEnabledColor = thumbUnEnabledColor; - thumbColorStateList = new XGradientHelper.ColorStateListBuilder() - .setUnSateColor(thumbColor) + if (thumbColor > 0) { + this.thumbColor = thumbColor; + } + if (thumbPressedColor > 0) { + this.thumbPressedColor = thumbPressedColor; + } + if (thumbCheckedColor > 0) { + this.thumbCheckedColor = thumbCheckedColor; + } + if (thumbUnEnabledColor > 0) { + this.thumbUnEnabledColor = thumbUnEnabledColor; + } + thumbColorStateList = new XGradientHelper.ColorStateListBuilder().setUnSateColor(thumbColor) .addPressedColor(thumbPressedColor) .addCheckedColor(thumbCheckedColor) .addUnEnabledColor(thumbUnEnabledColor) .build(); -// mCurrThumbColor = thumbColorStateList.getDefaultColor(); invalidate(); } } \ No newline at end of file