How do I do something when an animation finishes?

前端 未结 4 1102
攒了一身酷
攒了一身酷 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:34

    The more modern way of doing this is to use the ViewPropertyAnimator:

    view.animate()
        .alpha(0f)
        .withEndAction(new Runnable() {
          @Override
          public void run() {
            // Do something.
          }
        })
        .start();
    

    Or, if you're using RetroLambda:

    view.animate()
        .alpha(0f)
        .withEndAction(() -> {
          // Do something.
        })
        .start();
    

提交回复
热议问题