Thursday, March 12, 2020

Animation checkbox in Android

Animation checkbox in Android

build.gradle
implementation 'it.emperor.animatedcheckbox:animatedcheckbox:1.0.3'
If gradle failed to sync, try adding maven repository into project build.gradle
allprojects {
    repositories {
        maven {
            url  "https://dl.bintray.com/moro56/AnimatedCheckBox"
        }
    }
}
main_activity.xml
<it.emperor.animatedcheckbox.AnimatedCheckBox
    android:id="@+id/animatedcheckbox"
    android:layout_width="60dp"
    android:layout_height="60dp"
    app:acb_animation_duration="500"
    app:acb_border_checked_color="#000"
    app:acb_border_checked_stroke_width="2dp"
    app:acb_border_not_checked_color="#0f0"
    app:acb_checked="true"
    app:acb_circle_color="#f00"
    app:acb_hook_color="#00f"
    app:acb_hook_stroke_width="2dp"
    app:acb_padding="10dp" />
java code
animatedCheckBox.setChecked(true, true) // animated
animatedCheckBox.setChecked(false) // not animated
Event click
animatedCheckBox.setOnChangeListener {
    println("Is checked: " + it) // true or false
}
Animation checkbox in Android

No comments:

Post a Comment