Is there a way to listen for animation end in AnimatedVectorDrawables

前端 未结 4 882
一向
一向 2020-12-31 00:35

I have created an AnimatedVectorDrawable, it works pretty well, now I am looking for a way to change the animation or hide the view after it finishes. I was hoping there was

4条回答
  •  没有蜡笔的小新
    2020-12-31 01:08

    Not tried this yet but Android 6.0 has a registerAnimationCallback method from the Animatable2 interface for this

    Edit: yep this works in Android 6.0 emulator:

    mAnimatedVectorDrawable.registerAnimationCallback (new Animatable2.AnimationCallback(){
        public void onAnimationEnd(Drawable drawable){
            //Do something
        }
    }
    

    Edit2: looks like they haven't added support for this in the AnimatedVectorDrawableCompat from support lib 23.2+ :(

    Edit3: it looks like this got added in support lib 25.3.0

    Thanks Carson!

提交回复
热议问题