Android custom checkbox based on SmoothCheckBox
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.Stjin:android-custom-checkbox:Tag'
}
Attr | Type | Description |
---|---|---|
duration | integer | Animation Duration |
stroke_width | dimension | The border width when unchecked |
color_tick | color | Tick color (visible only when checked) |
color_checked | color | Fill color when selected |
color_unchecked | color | Fill color when unchecked |
color_unchecked_stroke | color | Border color when unchecked |
setChecked(boolean checked); //by default, it's wthout animation
setChecked(boolean checked,boolean animate); //pass true to animate
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample);
final CustomCheckBox scb=(CustomCheckBox)findViewById(R.id.scb);
scb.setOnCheckedChangeListener(new CustomCheckBox.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CustomCheckBox checkBox,boolean isChecked){
Log.d("CustomCheckBox",String.valueOf(isChecked));
}
});
}