From 94930904af3f4ba5d6acd2a25a85d74890e2d637 Mon Sep 17 00:00:00 2001 From: EGE Date: Sun, 20 Nov 2016 22:11:10 +0300 Subject: [PATCH] SegmentedButton's drawable positioning fix. --- .../segmentedbutton/SegmentedButton.java | 22 ++++--------------- .../segmentedbutton/SegmentedButtonGroup.java | 2 -- sample/src/main/res/layout/activity_main.xml | 21 +++++++++--------- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButton.java b/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButton.java index 80014e0..687ccbe 100644 --- a/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButton.java +++ b/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButton.java @@ -120,14 +120,17 @@ public void setDrawableTop(int drawableId) { public void setDrawableBottom(int drawableId) { setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, drawableId); + setImageTint(imageTint); } public void setDrawableLeft(int drawableId) { setCompoundDrawablesWithIntrinsicBounds(drawableId, 0, 0, 0); + setImageTint(imageTint); } public void setDrawableRight(int drawableId) { setCompoundDrawablesWithIntrinsicBounds(0, 0, drawableId, 0); + setImageTint(imageTint); } public boolean hasButtonWidth() { @@ -313,28 +316,11 @@ public int getImageTint() { return imageTint; } - public float getButtonImageScale() { return buttonImageScale; } - - public boolean isHasButtonImageTint() { + public boolean hasButtonImageTint() { return hasButtonImageTint; } - - /* - public void setHasButtonImageTint(boolean hasButtonImageTint) { - - this.hasButtonImageTint = hasButtonImageTint; - } - - public void setButtonImageScale(float buttonImageScale) { - this.buttonImageScale = buttonImageScale; - } - - public void setButtonImageTint(int imageTint) { - this.imageTint = imageTint; - } - */ } diff --git a/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButtonGroup.java b/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButtonGroup.java index ce310fa..5186cdc 100644 --- a/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButtonGroup.java +++ b/library/src/main/java/co/ceryle/segmentedbutton/SegmentedButtonGroup.java @@ -31,7 +31,6 @@ import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.support.v4.view.animation.LinearOutSlowInInterpolator; import android.util.AttributeSet; -import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateDecelerateInterpolator; @@ -796,7 +795,6 @@ public int getMargin() { @Override public Parcelable onSaveInstanceState() { - // Log.d(TAG, "onRestoreInstanceState: " + position); Bundle bundle = new Bundle(); bundle.putParcelable("state", super.onSaveInstanceState()); bundle.putInt("position", position); diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index c0e3a85..46daf7d 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -158,8 +158,7 @@ + app:sbg_shadowElevation="2dp" + app:sbg_shadowMargin="3dp"> + app:sbg_shadowElevation="2dp" + app:sbg_shadowMargin="3dp"> + app:sbg_shadowElevation="2dp" + app:sbg_shadowMargin="3dp"> + app:sbg_shadowElevation="2dp" + app:sbg_shadowMargin="3dp">