Skip to content

Commit

Permalink
fix round background
Browse files Browse the repository at this point in the history
  • Loading branch information
pichsy committed Mar 6, 2021
1 parent 1cbd5bb commit 5f28b1e
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 112 deletions.
90 changes: 45 additions & 45 deletions app/src/main/java/com/pichs/app/xwidget/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,55 @@ protected void onCreate(Bundle savedInstanceState) {
XStatusBarHelper.setStatusBarDarkMode(this);
setContentView(R.layout.activity_main);

XCardButton btn = findViewById(R.id.btn1);
XCheckBox checkbox = findViewById(R.id.checkbox);
checkbox.setOnCheckedChangeListener(new XCheckBox.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(boolean isChecked) {
Toast.makeText(getApplicationContext(), "ischecked:" + isChecked, Toast.LENGTH_LONG).show();
}
});
// XCardButton btn = findViewById(R.id.btn1);
// XCheckBox checkbox = findViewById(R.id.checkbox);
// checkbox.setOnCheckedChangeListener(new XCheckBox.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(boolean isChecked) {
// Toast.makeText(getApplicationContext(), "ischecked:" + isChecked, Toast.LENGTH_LONG).show();
// }
// });


XSwitchButton swb = findViewById(R.id.swb);
swb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

if (isChecked) {
checkbox.setImageDrawable(new ColorDrawable(Color.BLACK));
checkbox.setCheckedDrawable(new ColorDrawable(Color.RED));

} else {
checkbox.setImageDrawable(new ColorDrawable(Color.GREEN));
checkbox.setCheckedDrawable(new ColorDrawable(Color.BLUE));

}

}
});
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) {
XTypefaceHelper.setGlobalTypefaceFromAssets(getApplicationContext(), "leihong.ttf");
XTypefaceHelper.setGlobalTypefaceStyle(getApplicationContext(), XTypefaceHelper.NONE);
}
});
XButton normalBtn = findViewById(R.id.normalBtn);

normalBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// XSwitchButton swb = findViewById(R.id.swb);
// swb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
// @Override
// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//
// if (isChecked) {
// checkbox.setImageDrawable(new ColorDrawable(Color.BLACK));
// checkbox.setCheckedDrawable(new ColorDrawable(Color.RED));
//
// } else {
// checkbox.setImageDrawable(new ColorDrawable(Color.GREEN));
// checkbox.setCheckedDrawable(new ColorDrawable(Color.BLUE));
//
// }
//
// }
// });
// 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) {
// XTypefaceHelper.setGlobalTypefaceFromAssets(getApplicationContext(), "leihong.ttf");
// XTypefaceHelper.clearObserver();

// XTypefaceHelper.setGlobalTypeface(getApplicationContext(), XTypefaceHelper.TYPEFACE_BOLD);
XTypefaceHelper.resetTypeface(MainActivity.this);
// XTypefaceHelper.setGlobalTypefaceStyle(getApplicationContext(), XTypefaceHelper.NONE);
}
});
// }
// });
// XButton normalBtn = findViewById(R.id.normalBtn);

// normalBtn.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//// XTypefaceHelper.setGlobalTypefaceFromAssets(getApplicationContext(), "leihong.ttf");
//// XTypefaceHelper.clearObserver();
//
//// XTypefaceHelper.setGlobalTypeface(getApplicationContext(), XTypefaceHelper.TYPEFACE_BOLD);
// XTypefaceHelper.resetTypeface(MainActivity.this);
//// XTypefaceHelper.setGlobalTypefaceStyle(getApplicationContext(), XTypefaceHelper.NONE);
// }
// });

}
}
146 changes: 80 additions & 66 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@
app:layout_constraintTop_toBottomOf="@+id/btn1"
app:xp_ignoreGlobalTypeface="true" />

<com.pichs.common.widget.switcher.XSwitchButton
android:id="@+id/swb"
android:layout_width="80dp"
android:layout_height="30dp"
android:checked="false"
android:textColor="@color/white"
app:xp_swb_backgroundColor_switchOff="#A60EDD"
app:xp_swb_backgroundColor_switchOn="#4ee"
app:xp_swb_text_switchOff=""
app:xp_swb_text_switchOn=""
app:xp_swb_thumbCheckedColor="#F43F0E"
app:xp_swb_thumbColor="#fff"
app:xp_swb_thumbMargin="3dp"
app:xp_swb_thumbPressedColor="#000" />
<!-- <com.pichs.common.widget.switcher.XSwitchButton-->
<!-- android:id="@+id/swb"-->
<!-- android:layout_width="80dp"-->
<!-- android:layout_height="30dp"-->
<!-- android:checked="false"-->
<!-- android:textColor="@color/white"-->
<!-- app:xp_swb_backgroundColor_switchOff="#A60EDD"-->
<!-- app:xp_swb_backgroundColor_switchOn="#4ee"-->
<!-- app:xp_swb_text_switchOff="开"-->
<!-- app:xp_swb_text_switchOn="关"-->
<!-- app:xp_swb_thumbCheckedColor="#F43F0E"-->
<!-- app:xp_swb_thumbColor="#fff"-->
<!-- app:xp_swb_thumbMargin="3dp"-->
<!-- app:xp_swb_thumbPressedColor="#000" />-->

<com.pichs.common.widget.shinebutton.ShineButton
android:layout_width="40dp"
Expand All @@ -102,58 +102,72 @@
app:xp_shine_small_shine_color="#3CC63C" />


<com.pichs.common.widget.input.InputLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:hint="卫生间"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:text="十大发牢骚"
android:textColor="#f00"
android:textColorHint="#999"
android:textSize="18sp"
android:textStyle="bold"
app:xp_clearDrawable="#BD0CE8"
app:xp_clearIconVisible="false"
app:xp_eyeCloseDrawable="#0f8"
app:xp_eyeIconVisible="true"
app:xp_eyeOpenDrawable="#99f" />


<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="#D1EFE3"
android:orientation="vertical">

<com.pichs.common.widget.checkbox.XSmoothCheckBox
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"
app:xp_cbox_color_unchecked_stroke="#0ff" />

<com.pichs.common.widget.checkbox.XCheckBox
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/checkbox"
android:layout_gravity="center"
android:src="@drawable/ic_agree_unckecked"
app:xp_checked="true"
app:xp_src_checked="@drawable/ic_agree_checked" />

</LinearLayout>


<androidx.appcompat.widget.AppCompatCheckBox
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:layout_marginTop="10dp" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="师范生克拉夫" />
<!-- <com.pichs.common.widget.input.InputLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="48dp"-->
<!-- android:hint="卫生间"-->
<!-- android:paddingStart="16dp"-->
<!-- android:paddingEnd="16dp"-->
<!-- android:text="十大发牢骚"-->
<!-- android:textColor="#f00"-->
<!-- android:textColorHint="#999"-->
<!-- android:textSize="18sp"-->
<!-- android:textStyle="bold"-->
<!-- app:xp_clearDrawable="#BD0CE8"-->
<!-- app:xp_clearIconVisible="false"-->
<!-- app:xp_eyeCloseDrawable="#0f8"-->
<!-- app:xp_eyeIconVisible="true"-->
<!-- app:xp_eyeOpenDrawable="#99f" />-->

<com.pichs.common.widget.roundview.XRoundTextView
android:layout_marginTop="10dp"
android:layout_width="80dp"
android:layout_height="40dp"
android:gravity="center"
android:text="我就是深"
app:xp_pressedBorderColor="#f00"
app:xp_pressedTextColor="#f00"
android:clickable="true"
android:textColor="#000"
app:xp_borderColor="#000"
app:xp_borderWidth="2dp"
app:xp_radius="20dp" />


<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="80dp"-->
<!-- android:background="#D1EFE3"-->
<!-- android:orientation="vertical">-->

<!-- <com.pichs.common.widget.checkbox.XSmoothCheckBox-->
<!-- android:layout_width="30dp"-->
<!-- android:layout_height="30dp"-->
<!-- android:layout_gravity="center"-->
<!-- app:xp_cbox_color_unchecked_stroke="#0ff" />-->

<!-- <com.pichs.common.widget.checkbox.XCheckBox-->
<!-- android:layout_width="30dp"-->
<!-- android:layout_height="30dp"-->
<!-- android:id="@+id/checkbox"-->
<!-- android:layout_gravity="center"-->
<!-- android:src="@drawable/ic_agree_unckecked"-->
<!-- app:xp_checked="true"-->
<!-- app:xp_src_checked="@drawable/ic_agree_checked" />-->

<!-- </LinearLayout>-->


<!-- <androidx.appcompat.widget.AppCompatCheckBox-->
<!-- android:layout_width="100dp"-->
<!-- android:layout_height="100dp"-->
<!-- android:layout_gravity="center"-->
<!-- android:layout_marginTop="10dp" />-->

<!-- <EditText-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:hint="师范生克拉夫" />-->

<Space
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
Expand Down Expand Up @@ -217,7 +218,8 @@ private Drawable getFinalDrawable(int radius, int topLeftRadius, int topRightRad
builder.setFillColor(endColor);
return builder.build();
}
return null;
builder.setFillColor(Color.TRANSPARENT);
return builder.build();
}


Expand Down

0 comments on commit 5f28b1e

Please sign in to comment.