Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadAnimation.

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:Main.java

public static void startAnimation(View target, int aniResId, int duration) {
    if (target == null)
        return;//  ww  w . j a v a  2s.c o m

    Animation animation = AnimationUtils.loadAnimation(target.getContext(), aniResId);
    if (animation != null) {
        animation.setDuration(duration);
        target.startAnimation(animation);
    }
}

From source file:Main.java

public static Animation loadAnimation(Context context, int id) {

    Animation myAnimation = AnimationUtils.loadAnimation(context, id);
    return myAnimation;
}

From source file:Main.java

public static void showViewWithAnim(final View view, @AnimRes final int anim, final int delay) {
    new Thread(new Runnable() {
        @Override/*ww  w. ja v  a2s. co  m*/
        public void run() {
            sleep(delay);

            ((Activity) view.getContext()).runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    view.setVisibility(View.VISIBLE);
                    view.startAnimation(AnimationUtils.loadAnimation(view.getContext(), anim));

                }
            });
        }
    }).start();
}

From source file:Main.java

public static void startAnimation(View target, int aniResId, AnimationListener listener) {
    if (target == null) {
        return;/*  w ww.ja va 2s  .  c  o  m*/
    }

    Animation animation = AnimationUtils.loadAnimation(target.getContext(), aniResId);
    if (animation == null) {
        return;
    }

    if (listener != null) {
        animation.setAnimationListener(listener);
    }

    target.startAnimation(animation);
}

From source file:Main.java

public static void playAnimation(Context context, int animationId, View v) {
    Animation a = AnimationUtils.loadAnimation(context, animationId);
    v.startAnimation(a);// w ww. j a  v a2 s . com
}

From source file:Main.java

public static Animation getAnimation(Context context, int anim_res) {
    return AnimationUtils.loadAnimation(context, anim_res);
}

From source file:Main.java

public static void playPlAnimation(Context context, View view, int animId) {
    Animation anim = AnimationUtils.loadAnimation(context, animId);
    anim.setFillAfter(true);//w  w w .  j  a v a2 s .  co  m
    view.startAnimation(anim);
}

From source file:Main.java

public static void startAnimation(View target, int aniResId, AnimationListener listener) {
    if (target == null)
        return;/* w w w.j  a  v a 2  s  .  c o m*/

    Animation animation = AnimationUtils.loadAnimation(target.getContext(), aniResId);
    if (animation != null) {
        if (listener != null) {
            animation.setAnimationListener(listener);
        }
        target.startAnimation(animation);
    }
}

From source file:Main.java

public static void addAnimationToView(final View view, final int animation) {
    if (view == null) {
        return;/* w  ww. j  av  a2 s .co m*/
    }
    Animation anim = AnimationUtils.loadAnimation(view.getContext(), animation);
    anim.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.setVisibility(View.VISIBLE);
        }
    });
    view.startAnimation(anim);
}

From source file:Main.java

public static void startAnimation(View target, int aniResId, int duration, AnimationListener listener) {
    if (target == null) {
        return;//from   w  w  w  . j  ava2 s .c  o m
    }

    Animation animation = AnimationUtils.loadAnimation(target.getContext(), aniResId);

    if (animation == null) {
        return;
    }

    if (listener != null) {
        animation.setAnimationListener(listener);
    }

    animation.setDuration(duration);
    target.startAnimation(animation);
}