Skip to content

Commit

Permalink
add method
Browse files Browse the repository at this point in the history
  • Loading branch information
pichsy committed Feb 25, 2021
1 parent 07d2710 commit 0583f1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/src/main/java/com/pichs/app/xwidget/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import android.widget.TextView;

import com.pichs.common.widget.cardview.XCardButton;
import com.pichs.common.widget.switcher.XSwitchButton;
import com.pichs.common.widget.utils.XTypefaceHelper;
import com.pichs.common.widget.view.XButton;

Expand All @@ -24,6 +25,10 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

XCardButton btn = findViewById(R.id.btn1);
XSwitchButton swb = findViewById(R.id.swb);

swb.setThumbColor(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK );
swb.setBackgroundColor(Color.GREEN, Color.CYAN);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

<com.pichs.common.widget.switcher.XSwitchButton
android:layout_width="180dp"
android:id="@+id/swb"
android:layout_height="60dp"
android:checked="false"
android:textColor="@color/white"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ public void setBackgroundColor(int offColor, int onColor) {
invalidate();
}

public void setThumbColor(int thumbColor, int thumbPressedColor, int thumbCheckedColor, int thumbUnEnabledColor) {
public void setThumbColor(int thumbColor, int thumbCheckedColor, int thumbPressedColor, int thumbUnEnabledColor) {
this.thumbColor = thumbColor;
this.thumbPressedColor = thumbPressedColor;
this.thumbCheckedColor = thumbCheckedColor;
Expand All @@ -1070,7 +1070,7 @@ public void setThumbColor(int thumbColor, int thumbPressedColor, int thumbChecke
.addCheckedColor(thumbCheckedColor)
.addUnEnabledColor(thumbUnEnabledColor)
.build();
mCurrThumbColor = thumbColorStateList.getColorForState(getDrawableState(), mCurrThumbColor);
// mCurrThumbColor = thumbColorStateList.getDefaultColor();
invalidate();
}
}

0 comments on commit 0583f1e

Please sign in to comment.