Usage
Gradle
implementation "com.rizlee.wrapper:vector-anim-wrapper:$last_version"
XML
<com.rizlee.animatedicon.AnimatedIcon
android:id="@+id/animatedIcon"
android:layout_width="50dp"
android:layout_height="50dp"
app:first_state="@drawable/play_to_pause"
app:last_state="@drawable/pause_to_play" />
Kotlin
just implement:
AnimatedIcon.OnAnimatedIconClickListener
AnimatedIcon.OnAnimatedIconCallback // only for api >= 23
then animatedIcon.listener = this
animatedIcon.animCallback = this // only for api >= 23
override fun onClickEvent(newState: AnimatedIcon.State) {
when (newState) {
AnimatedIcon.State.FIRST_STATE -> Log.i(TAG, "First state")
AnimatedIcon.State.LAST_STATE -> Log.i(TAG, "Last state")
}
}
override fun onStateChanged(newState: AnimatedIcon.State) {
when (newState) {
AnimatedIcon.State.FIRST_STATE -> Log.i(TAG, "First state")
AnimatedIcon.State.LAST_STATE -> Log.i(TAG, "Last state")
}
}
override fun onAnimationStart() {
Log.i(TAG, "onAnimationStart")
}
override fun onAnimationEnd() {
Log.i(TAG, "onAnimationEnd")
}
animatedIcon.setCurrentStateWithAnim(AnimatedIcon.State.FIRST_STATE)
animatedIcon.currentState // get the current state
Animated drawables you can make with the help of this, In sample you can find examples of vector drawables