How do I do something when an animation finishes?

前端 未结 4 1103
攒了一身酷
攒了一身酷 2020-12-01 08:51

I have an ImageView that I use to show progress via an AnimationDrawable. When I want to show my progress spinner, I do this:

anim         


        
4条回答
  •  执笔经年
    2020-12-01 09:31

    To your original question about the ObjectAnimator object you can set up an Animator.AnimatorListener object which defines several animation state callbacks. You want to override public void onAnimationEnd(Animator animation)

    animation.addListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animation) {
    
                    }
    
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        Toast.makeText(VideoEditorActivity.this, "animation ended", Toast.LENGTH_LONG).show();
                    }
    
                    @Override
                    public void onAnimationCancel(Animator animation) {
    
                    }
    
                    @Override
                    public void onAnimationRepeat(Animator animation) {
    
                    }
                });
    

提交回复
热议问题