Example usage for android.view.animation TranslateAnimation setDuration

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

Introduction

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

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:Main.java

public static void showViewFromBottom(View view) {
    if (view.getVisibility() == View.VISIBLE) {
        return;/*  w  w w  .  ja  v a 2  s.  c o m*/
    }
    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

/**
 * translate the view./* ww  w  . j a v a  2s. c  o m*/
 *
 * @param view           view to be translated
 * @param fromXDelta     Change in X coordinate to apply at the start of the
 *                       animation
 * @param toXDelta       Change in X coordinate to apply at the end of the
 *                       animation
 * @param fromYDelta     Change in Y coordinate to apply at the start of the
 *                       animation
 * @param toYDelta       Change in Y coordinate to apply at the end of the
 *                       animation
 * @param cycles         Repeats the animation for a specified number of cycles {@link CycleInterpolator}.
 * @param durationMillis Duration in milliseconds
 * @param isBanClick     whether view can click in animation
 */
public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta,
        float toYDelta, float cycles, long durationMillis, final boolean isBanClick) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translateAnimation.setDuration(durationMillis);
    if (cycles > 0.0) {
        translateAnimation.setInterpolator(new CycleInterpolator(cycles));
    }
    translateAnimation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            if (isBanClick) {
                view.setClickable(false);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isBanClick) {
                view.setClickable(true);
            }
        }
    });
    view.startAnimation(translateAnimation);
}

From source file:Main.java

public static Animation slideOutFromBottom() {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1.0f);
    animation.setDuration(300);
    return animation;
}

From source file:Main.java

public static Animation slideOutFromTop() {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1.0f);
    animation.setDuration(300);
    return animation;
}

From source file:Main.java

public static Animation createFromSouthInAnimation() {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0,
            Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
    animation.setDuration(500);
    return animation;
}

From source file:Main.java

public static Animation createFromSouthEastInAnimation() {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 1,
            Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_PARENT, 0);
    animation.setDuration(500);
    return animation;
}

From source file:Main.java

public static Animation createToSouthOutAnimation() {
    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0,
            Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 1);
    animation.setDuration(500);
    return animation;
}

From source file:Main.java

public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta,
        float toYDelta, float cycles, long durationMillis, final boolean isBanClick) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    translateAnimation.setDuration(durationMillis);
    if (cycles > 0.0) {
        translateAnimation.setInterpolator(new CycleInterpolator(cycles));
    }/*from ww w .  ja v a2 s . c o m*/
    translateAnimation.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            if (isBanClick) {
                view.setClickable(false);
            }
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            if (isBanClick) {
                view.setClickable(true);
            }
        }
    });
    view.startAnimation(translateAnimation);
}

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