How do I do something when an animation finishes?

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();

Leave a Comment