create Height Animator - Android android.animation

Android examples for android.animation:Animator

Description

create Height Animator

Demo Code


import android.animation.Animator;
import android.animation.ValueAnimator;
import android.view.View;

public class Main {
  private static Animator createHeightAnimator(final View view, int from, int to) {
    ValueAnimator animator = ValueAnimator.ofInt(from, to);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
      @Override//from w  w w.j a v  a  2s  . c om
      public void onAnimationUpdate(ValueAnimator animation) {
        Integer value = (Integer) animation.getAnimatedValue();
        view.getLayoutParams().height = value;
        view.requestLayout();
      }
    });
    return animator;
  }
}

Related Tutorials