Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
SegmentedButton's drawable positioning fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceryle committed Nov 20, 2016
1 parent 5900574 commit 9493090
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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;
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 10 additions & 11 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@
<co.ceryle.segmentedbutton.SegmentedButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/b5"
android:drawablePadding="4dp"
android:drawableTop="@drawable/b5"
android:padding="4dp"
android:text="Diana"
android:textColor="@color/black"
Expand All @@ -171,7 +170,7 @@
<co.ceryle.segmentedbutton.SegmentedButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/b3"
android:drawableRight="@drawable/b3"
android:drawablePadding="4dp"
android:padding="4dp"
android:text="Clark"
Expand Down Expand Up @@ -204,8 +203,8 @@
app:sbg_selectorColor="@color/yellow_600"
app:sbg_selectorImageTint="@color/black"
app:sbg_shadow="true"
app:sbg_shadowElevation="5dp"
app:sbg_shadowMargin="6dp">
app:sbg_shadowElevation="2dp"
app:sbg_shadowMargin="3dp">

<co.ceryle.segmentedbutton.SegmentedButton
android:layout_width="wrap_content"
Expand Down Expand Up @@ -238,8 +237,8 @@
app:sbg_rippleColor="@color/black"
app:sbg_selectorColor="@color/DarkRed"
app:sbg_shadow="true"
app:sbg_shadowElevation="5dp"
app:sbg_shadowMargin="6dp">
app:sbg_shadowElevation="2dp"
app:sbg_shadowMargin="3dp">

<co.ceryle.segmentedbutton.SegmentedButton
android:layout_width="wrap_content"
Expand Down Expand Up @@ -276,8 +275,8 @@
app:sbg_selectorColor="@color/green_200"

app:sbg_shadow="true"
app:sbg_shadowElevation="5dp"
app:sbg_shadowMargin="6dp">
app:sbg_shadowElevation="2dp"
app:sbg_shadowMargin="3dp">

<co.ceryle.segmentedbutton.SegmentedButton
android:layout_width="wrap_content"
Expand Down Expand Up @@ -330,8 +329,8 @@
app:sbg_selectorColor="@color/white"
app:sbg_selectorImageTint="@color/black"
app:sbg_shadow="true"
app:sbg_shadowElevation="5dp"
app:sbg_shadowMargin="6dp">
app:sbg_shadowElevation="2dp"
app:sbg_shadowMargin="3dp">

<co.ceryle.segmentedbutton.SegmentedButton
android:layout_weight="1"
Expand Down

0 comments on commit 9493090

Please sign in to comment.