Example usage for android.view.animation AnimationSet addAnimation

List of usage examples for android.view.animation AnimationSet addAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationSet addAnimation.

Prototype

public void addAnimation(Animation a) 

Source Link

Document

Add a child animation to this animation set.

Usage

From source file:Main.java

public static void showAnimation(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);//from   www  .  j  a  v a  2 s .c  om
}

From source file:Main.java

public static void backAnimation(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);//from ww  w .  j  a v a 2 s .  co m
}

From source file:Main.java

public static void backAnimationFromBottom(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);//from w w w  . j ava 2s  .  co  m
}

From source file:Main.java

public static void showAnimationFromTop(View view) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1f, Animation.RELATIVE_TO_SELF, 0f);
    translateAnimation.setDuration(200);
    animationSet.addAnimation(translateAnimation);
    view.startAnimation(animationSet);/* w ww.j  ava 2  s .c  om*/
}

From source file:Main.java

public static void popup(View view) {

    AnimationSet animation = new AnimationSet(true);
    float pivotX = view.getWidth() / 2;
    float pivotY = view.getHeight() / 2;
    ScaleAnimation anim = new ScaleAnimation(0f, 1.1f, 0f, 1.1f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(300);//  w ww .  j  a v  a2  s  . c  o  m
    animation.addAnimation(anim);

    anim = new ScaleAnimation(1.1f, 1f, 1.1f, 1f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(100);
    anim.setStartOffset(300);
    animation.addAnimation(anim);

    view.startAnimation(animation);
}

From source file:Main.java

public static AnimationSet setExitAnimation(int AnimationType, float fromX, float toX, float fromY, float toY,
        float scaleX, float scaleToX, float scaleY, float scaleToY, float pinX, float pinY) {
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(AnimationType, fromX, AnimationType, toX,
            AnimationType, fromY, AnimationType, toY);
    ScaleAnimation scaleAnimation = new ScaleAnimation(scaleX, scaleToX, scaleY, scaleToY, AnimationType, pinX,
            AnimationType, pinY);/*from ww  w .j  ava  2  s.c  om*/
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(300);
    return animationSet;
}

From source file:Main.java

public static AnimationSet startInfoAnimation(int AnimationType, float fromX, float toX, float fromY, float toY,
        float scaleX, float scaleToX, float scaleY, float scaleToY, float pinX, float pinY) {
    OvershootInterpolator overshootInterpolator = new OvershootInterpolator(2f);
    AnimationSet animationSet = new AnimationSet(true);
    TranslateAnimation translateAnimation = new TranslateAnimation(AnimationType, fromX, AnimationType, toX,
            AnimationType, fromY, AnimationType, toY);
    ScaleAnimation scaleAnimation = new ScaleAnimation(scaleX, scaleToX, scaleY, scaleToY, AnimationType, pinX,
            AnimationType, pinY);/*from   w  ww  . j  a v a 2s  . c  o m*/
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(300);
    animationSet.setFillAfter(true);
    animationSet.setInterpolator(overshootInterpolator);
    return animationSet;
}

From source file:Main.java

public static void shrinkToLeft(FragmentActivity activity, View view, AnimationListener listener) {

    DisplayMetrics displaymetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenHeight = displaymetrics.heightPixels;
    int screenWidth = displaymetrics.widthPixels;

    AnimationSet animation = new AnimationSet(true);
    float pivotX = view.getWidth() / 2;
    float pivotY = view.getHeight() / 2;
    ScaleAnimation anim = new ScaleAnimation(1f, 0.8f, 1f, 0.8f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(200);//  www.j  a  v a2s.c o  m
    anim.setStartOffset(200);
    //anim.setFillAfter(true);
    animation.addAnimation(anim);

    TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) -(screenWidth - view.getWidth()), 0.0f,
            0.0f);
    anim.setInterpolator(new LinearInterpolator());
    animTrans.setDuration(400);
    //animTrans.setStartOffset(300);
    animation.addAnimation(animTrans);

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

    view.startAnimation(animation);
}

From source file:Main.java

public static void enlargeToRight(FragmentActivity activity, View view, AnimationListener listener) {

    DisplayMetrics displaymetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int screenHeight = displaymetrics.heightPixels;
    int screenWidth = displaymetrics.widthPixels;

    AnimationSet animation = new AnimationSet(true);
    float pivotX = view.getWidth() / 2;
    float pivotY = view.getHeight() / 2;
    ScaleAnimation anim = new ScaleAnimation(0.8f, 1f, 0.8f, 1f, pivotX, pivotY);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(200);//ww  w  . ja  v a2s  .  c  o m
    anim.setStartOffset(200);
    //anim.setFillAfter(true);
    animation.addAnimation(anim);

    TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) (screenWidth - view.getWidth()), 0.0f,
            0.0f);
    anim.setInterpolator(new LinearInterpolator());
    animTrans.setDuration(400);
    //animTrans.setStartOffset(300);
    animation.addAnimation(animTrans);

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

    view.startAnimation(animation);
}

From source file:Main.java

public static AnimationSet FlipAnimation(int duration, int repeatCount) {
    AnimationSet flip = new AnimationSet(true);
    if (duration > 20) //Flip anim
    {// ww  w .j av a  2s  .  c  o  m
        Animation from_middle1_anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,
                .5f, Animation.RELATIVE_TO_SELF, .5f);
        from_middle1_anim.setDuration(duration);
        from_middle1_anim.setStartOffset(0);
        from_middle1_anim.setRepeatMode(Animation.REVERSE);
        from_middle1_anim.setRepeatCount(repeatCount);

        flip.addAnimation(from_middle1_anim);
    } else // no anim
    {
        Animation noAnim = new AlphaAnimation(1f, 1f);
        noAnim.setDuration(duration);
        flip.addAnimation(noAnim);
    }
    return flip;
}