Example usage for android.view.animation AnimationSet AnimationSet

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

Introduction

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

Prototype

public AnimationSet(boolean shareInterpolator) 

Source Link

Document

Constructor to use when building an AnimationSet from code

Usage

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.  ja v a2s  .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  ww w.  j  a v a2 s .  co  m
}

From source file:Main.java

private static void ApplyHorizontalScrollAnimation(View view, boolean left, int speed) {
    float sign = left ? 1f : -1f;
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setRepeatCount(Animation.INFINITE);
    animationSet.setRepeatMode(Animation.RESTART);

    TranslateAnimation move = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, sign * 0.70f,
            Animation.RELATIVE_TO_PARENT, sign * -0.70f, Animation.RELATIVE_TO_PARENT, 0,
            Animation.RELATIVE_TO_PARENT, 0);
    move.setStartOffset(0);//  ww w .  jav a 2s. c o  m
    move.setDuration(speed);
    move.setFillAfter(true);
    animationSet.addAnimation(move);
    view.startAnimation(animationSet);
}

From source file:Main.java

public static GridLayoutAnimationController getLayoutAnimation() {
    AnimationSet set = new AnimationSet(true);
    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(40);//w  ww.  j a  v  a2s  .  c  om
    set.addAnimation(animation);
    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(75);
    set.addAnimation(animation);
    GridLayoutAnimationController controller = new GridLayoutAnimationController(set);
    return controller;
}

From source file:Main.java

public static void makeViewGroupAnimation(ViewGroup viewGroup) {
    AnimationSet set = new AnimationSet(true);

    Animation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(50);//  w  w w.  jav a 2 s.co  m
    set.addAnimation(animation);

    animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
    animation.setDuration(150);
    set.addAnimation(animation);

    LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
    viewGroup.setLayoutAnimation(controller);
}

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);//w ww .  ja  v  a 2 s . com
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(300);
    return animationSet;
}

From source file:Main.java

public static AnimationSet translate(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
        int duration) {
    Animation animation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    animation.setDuration(duration);//from w ww  .j av  a  2  s.co m

    AnimationSet animationSet = new AnimationSet(true);
    // animationSet.setInterpolator(new AccelerateInterpolator());
    animationSet.addAnimation(animation);
    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  w  w .  jav  a2s .  co 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 AnimationSet ShuffleAnimation(int deltaX, int deltaY) {

    TranslateAnimation shake_1 = new TranslateAnimation(0, deltaX, 0, deltaY);
    shake_1.setDuration(400);// ww w.  j ava 2s  .  c om
    shake_1.setStartOffset(0);
    shake_1.setFillAfter(true);
    TranslateAnimation shake_2 = new TranslateAnimation(0, -deltaX, 0, -deltaY);
    shake_2.setDuration(400);
    shake_2.setStartOffset(400);
    shake_2.setFillAfter(true);
    AnimationSet ShakeIt = new AnimationSet(true);
    ShakeIt.addAnimation(shake_1);
    ShakeIt.addAnimation(shake_2);
    ShakeIt.setInterpolator(new OvershootInterpolator());

    return ShakeIt;
}

From source file:Main.java

public static void postAnimation(final View childLayout, int delay, final int duration) {
    int visibility = childLayout.getVisibility();
    if (visibility != View.VISIBLE) {
        return;/*from w w w.  j av a2 s  .  co  m*/
    }
    childLayout.setVisibility(View.INVISIBLE);
    childLayout.postDelayed(new Runnable() {
        @Override
        public void run() {
            childLayout.setVisibility(View.VISIBLE);
            AnimationSet animationSet = new AnimationSet(true);
            animationSet.setDuration(duration);
            animationSet.setInterpolator(new OvershootInterpolator(0.8f));
            int pivotXType = Animation.RELATIVE_TO_SELF;
            animationSet.addAnimation(
                    new TranslateAnimation(pivotXType, -1, pivotXType, 0, pivotXType, 0, pivotXType, 0));
            animationSet.addAnimation(new AlphaAnimation(0, 1));
            childLayout.startAnimation(animationSet);
        }
    }, delay);
}