Use ObjectAnimator to animate on translationY - Android Animation

Android examples for Animation:Translate Animation

Description

Use ObjectAnimator to animate on translationY

Demo Code


import android.animation.ObjectAnimator;
import android.support.v7.widget.RecyclerView;

public class Main{
    public static void animate(RecyclerView.ViewHolder holder,
            boolean goesDown) {
        ObjectAnimator animatorTranslateY = ObjectAnimator.ofFloat(
                holder.itemView, "translationY", goesDown == true ? 200
                        : -200, 0);/*from w  w  w  .  j  av  a  2 s.c o  m*/
        animatorTranslateY.setDuration(500);
        animatorTranslateY.start();
    }
}

Related Tutorials