Animates the view to the given x/y coordinates using the given duration and calling the given Runnable once the animation completes. - Android User Interface

Android examples for User Interface:View Animation

Description

Animates the view to the given x/y coordinates using the given duration and calling the given Runnable once the animation completes.

Demo Code


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

public class Main{

    public static void animateXY(final View pView, final int pX,
            final int pY, final int pDuration, final Runnable pEndAction) {
        if (AndroidUtils.isUIThread()) {
            pView.animate().setDuration(pDuration).x(pX).y(pY)
                    .withEndAction(pEndAction);
        } else {//from w  ww  .  ja  v a  2 s.c  o m
            pView.post(new Runnable() {
                public void run() {
                    animateXY(pView, pX, pY, pDuration, pEndAction);
                }
            });
        }
    }
}

Related Tutorials