create Transition from ObjectAnimator - Android android.view.animation

Android examples for android.view.animation:ObjectAnimator

Description

create Transition from ObjectAnimator

Demo Code

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;

public class Main {

  public static Animator createXTransition(View view, boolean enter) {
    ObjectAnimator x;/*from   w w  w .ja  v  a  2 s  .c  o  m*/
    ObjectAnimator y;
    if (enter) {
      x = ObjectAnimator.ofFloat(view, "translationX", 1f, 0f);
      y = ObjectAnimator.ofFloat(view, "translationY", 1f, 0f);
    } else {
      x = ObjectAnimator.ofFloat(view, "translationX", 0f, -1f);
      y = ObjectAnimator.ofFloat(view, "translationY", 0f, -1f);
    }

    AnimatorSet set = new AnimatorSet();
    set.playTogether(x, y);
    return set;
  }

}

Related Tutorials