Runs the given animation on the given view. - Android User Interface

Android examples for User Interface:View Animation

Description

Runs the given animation on the given view.

Demo Code


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

public class Main{

    public static void runAnimation(final int pAnimationId, final View pView) {
        if (AndroidUtils.isUIThread()) {
            Animation anim = AnimationUtils.loadAnimation(
                    pView.getContext(), pAnimationId);
            pView.startAnimation(anim);// w ww. j a  va  2  s  . c om
        } else {
            pView.post(new Runnable() {
                public void run() {
                    runAnimation(pAnimationId, pView);
                }
            });
        }
    }
}

Related Tutorials