Android examples for android.animation:ObjectAnimator
of Property Values Holder ObjectAnimator
//package com.java2s; import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import java.util.HashSet; public class Main { private static HashSet<Animator> sAnimators = new HashSet<Animator>(); static Animator.AnimatorListener sEndAnimListener = new Animator.AnimatorListener() { public void onAnimationStart(Animator animation) { }/* ww w. j a v a 2 s. c o m*/ public void onAnimationRepeat(Animator animation) { } public void onAnimationEnd(Animator animation) { sAnimators.remove(animation); } public void onAnimationCancel(Animator animation) { sAnimators.remove(animation); } }; public static ObjectAnimator ofPropertyValuesHolder(Object target, PropertyValuesHolder... values) { ObjectAnimator anim = new ObjectAnimator(); anim.setTarget(target); anim.setValues(values); cancelOnDestroyActivity(anim); return anim; } public static void cancelOnDestroyActivity(Animator a) { sAnimators.add(a); a.addListener(sEndAnimListener); } }