ItsJustme ItsJustme - 3 months ago 22
Java Question

Detect end of animation (Android Studio)

I would like to know how you detect the end of an animation.
Here is the animation:

image.animate().xBy(screenWidth-200).setDuration(5000).start();

Answer

Are you trying to execute some action after the animation ends? If so try modifying your code like below :

   image.animate()
        .xBy(screenWidth-200)
        .setDuration(5000)
        .withEndAction(new Runnable() {
          @Override
          public void run() {
            // Do something when animation ends
          }
        })
        .start();