Example usage for android.view.animation TranslateAnimation TranslateAnimation

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

Introduction

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

Prototype

public TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType,
        float fromYValue, int toYType, float toYValue) 

Source Link

Document

Constructor to use when building a TranslateAnimation from code

Usage

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);//www . j a v  a  2 s.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);/*from  ww w.  j ava  2  s .  c  om*/
}

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 ww .j  a  v a  2 s .c  om
}

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);/*from   w w w. j  av  a  2  s  .c o m*/
    move.setDuration(speed);
    move.setFillAfter(true);
    animationSet.addAnimation(move);
    view.startAnimation(animationSet);
}

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  w w  .j  ava 2s  .c  o  m
    animationSet.addAnimation(translateAnimation);
    animationSet.addAnimation(scaleAnimation);
    animationSet.setDuration(300);
    return 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 . ja va  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(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);/*from  w  w  w  .ja v a 2 s .  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(150);
    set.addAnimation(animation);

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

From source file:Main.java

public static void showViewFromBottom(View view) {
    if (view.getVisibility() == View.VISIBLE) {
        return;//from  w  w  w . ja  v a  2  s  .  com
    }
    view.setVisibility(View.VISIBLE);
    int height = view.getHeight();
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, height, Animation.ABSOLUTE, 0);
    translateAnimation.setDuration(ANIMATION_DURATION);
    translateAnimation.setInterpolator(sAnimationInterpolator);
    view.startAnimation(translateAnimation);
}

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 ava 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 animation(View paramView) {
    TranslateAnimation localTranslateAnimation = new TranslateAnimation(2, 1.0F, 2, 0.0F, 2, 0.0F, 2, 0.0F);
    AlphaAnimation localAlphaAnimation = new AlphaAnimation(0.0F, 1.0F);
    AnimationSet localAnimationSet = new AnimationSet(false);
    localAnimationSet.addAnimation(localTranslateAnimation);
    localAnimationSet.addAnimation(localAlphaAnimation);
    animation(paramView, localAnimationSet, 1000L, 0L);
}