Example usage for android.view.animation Animation setDuration

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

Introduction

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

Prototype

public void setDuration(long durationMillis) 

Source Link

Document

How long this animation should last.

Usage

From source file:Main.java

public static Animation shakeUpAndDownAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 0, 0, 10);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}

From source file:Main.java

public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(1000);
    return translateAnimation;
}

From source file:Main.java

public static Animation getScaleAnimation(float fromX, float toX, float fromY, float toY, long duration) {
    Animation alpha = new ScaleAnimation(fromX, toX, fromY, toY, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    alpha.setDuration(duration);
    alpha.setFillAfter(true);/*from www . ja v a2s  . c  om*/
    return alpha;
}

From source file:Main.java

public static void startAnimation(View target, int aniResId, int duration) {
    if (target == null)
        return;//from  w  w w  .  j  a  va 2  s .  co  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 getSmallerAnimation(int duration) {
    Animation animation = new ScaleAnimation(1.0f, 0f, 1.0f, 0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(duration);
    animation.setFillAfter(true);//w  w w. j  a v  a  2 s . co  m
    return animation;
}

From source file:Main.java

protected static void show(final View view) {
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setStartOffset(500);/*from   w w  w. j  a  v  a  2 s. com*/
    fadeIn.setDuration(500);

    Animation collapse = new ScaleAnimation(1, 1, 0, 1);
    collapse.setDuration(500);

    AnimationSet animation = new AnimationSet(false);
    animation.setInterpolator(new AccelerateInterpolator());
    animation.addAnimation(collapse);
    animation.addAnimation(fadeIn);

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            view.setVisibility(View.VISIBLE);
        }

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

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    view.startAnimation(animation);
}

From source file:Main.java

public static Animation getFadeOutAnimation(int durationInMilliseconds) {
    final Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setFillAfter(true);//w  w  w  .  ja v  a2  s  . c  om
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setDuration(durationInMilliseconds);
    return fadeOut;
}

From source file:Main.java

public static Animation getUpAnimation(int height) {
    Animation animation = new TranslateAnimation(Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0,
            Animation.ABSOLUTE, height, Animation.ABSOLUTE, 0);
    animation.setDuration(800);
    //        animation.setFillAfter(true);
    return animation;
}

From source file:Main.java

public static void startScaleAnimationOn(View view, float startScale, float endScale, long duration) {
    Animation anim = new ScaleAnimation(1f, 1f, startScale, endScale, Animation.ABSOLUTE, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    anim.setDuration(duration);
    anim.setFillAfter(true);/*w ww . jav  a2 s.  co  m*/
    view.startAnimation(anim);
}

From source file:Main.java

public static void setPraiseAnimation(Animation... animations) {
    for (Animation animation : animations) {
        animation.setFillAfter(true);/*  w ww . ja  v  a 2s. c  o m*/
        animation.setFillBefore(true);
        animation.setFillEnabled(true);
        animation.setDuration(50);
    }
}