Animates the view by translating the view in the y direction by the specified y value using the given duration. - Android Animation

Android examples for Animation:Translate Animation

Description

Animates the view by translating the view in the y direction by the specified y value using the given duration.

Demo Code


import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

public class Main{

    public static void translationYBy(final View pView, final float pValue,
            final int pDuration, final Runnable pEndAction) {
        if (AndroidUtils.isUIThread()) {
            pView.animate().setDuration(pDuration).translationYBy(pValue)
                    .withEndAction(pEndAction);
        } else {//  w  w  w  .  j  a v a  2 s .  c om
            pView.post(new Runnable() {
                public void run() {
                    translationYBy(pView, pValue, pDuration, pEndAction);
                }
            });
        }
    }
}

Related Tutorials