Created this switch animation from Oleg Frolov as an android library.
Just add CheckboxSwitcher view in your layout XML and CheckboxSwitcher library in your project via Gradle:
dependencies {
implementation 'com.bitvale:checkboxswitcher:1.0.0'
}
<com.bitvale.checkboxswitcher.CheckboxSwitcher
android:id="@+id/switcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:switcher_bg_color="@color/switcher_color"
app:thumb_off_color="@color/off_color"
app:thumb_on_color="@color/icon_color"
app:thumb_icon="@drawable/thumb_icon" />
You must use the following properties in your XML to change your Switcher.
android:checked
(boolean) -> default falseapp:switcher_height
(dimension) -> default 26dp // width is calculated automaticallyapp:switcher_bg_color
(color) -> default whiteapp:thumb_on_color
(color) -> default #95cd75app:thumb_off_color
(color) -> default #e5e5e5app:thumb_icon
(reference) -> default check iconapp:elevation
(dimension) -> default 4dp
switcher.setOnCheckedChangeListener { checked ->
if (checked) action()
}
CheckboxSwitcher by Alexander Kolpakov is licensed under an Apache License 2.0.