set Listeners for Animator - Android android.view.animation

Android examples for android.view.animation:Animation

Description

set Listeners for Animator

Demo Code

import android.animation.Animator;
import android.os.Handler;
import android.view.View;

public class Main {

   static void setListeners(final View target, Animator anim, final Animator animator, final int duration) {
    anim.addListener(new Animator.AnimatorListener() {
      @Override// ww w  . j a v a  2  s.c o  m
      public void onAnimationStart(Animator animat) {
        if (target.getVisibility() == View.INVISIBLE) {
          target.setVisibility(View.VISIBLE);
        }
        new Handler().postDelayed(new Runnable() {
          @Override
          public void run() {
            animator.start();
          }
        }, duration - 100);
      }

      @Override
      public void onAnimationEnd(Animator animator) {

      }

      @Override
      public void onAnimationCancel(Animator animator) {

      }

      @Override
      public void onAnimationRepeat(Animator animator) {

      }
    });
  }

}

Related Tutorials