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

@SuppressLint("NewApi")
public static Animation makeVisibleAnimated(final View view) {
    final Animation a = new AlphaAnimation(0.00f, 1.00f);
    a.setDuration(500);
    a.setAnimationListener(getFadeInListener(view));

    view.startAnimation(a);/* w  w  w .  ja  v a  2  s  . c  o  m*/

    return a;
}

From source file:Main.java

/**
 * Fade in a view with the default time/*w  w  w .j a  va  2 s  .  co  m*/
 * @param view The {@link View} to use
 */
public static void fadeOut(View view) {
    if (view.getVisibility() != View.VISIBLE)
        return;

    // Since the button is still clickable before fade-out animation
    // ends, we disable the button first to block click.
    view.setEnabled(false);
    Animation animation = new AlphaAnimation(1F, 0F);
    animation.setDuration(400);
    view.startAnimation(animation);
    view.setVisibility(View.GONE);
}

From source file:Main.java

public static Animation getTranlateAnmation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta,
        int millisSecond) {
    Animation animation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta);
    animation.setDuration(millisSecond);
    return animation;
}

From source file:Main.java

public static Animation inFromBottomToTopAnimation() {
    Animation surfaceGrowingAnimation = new TranslateAnimation(0, 0, 100, Animation.ZORDER_TOP);
    surfaceGrowingAnimation.setDuration(500);
    return surfaceGrowingAnimation;
}

From source file:Main.java

/**
 * This method will cause a view to fade out after which it fires a callback where operations can be performed then it will fade back in
 * @param view the view to fade/*from www.j  av  a 2s. com*/
 * @param callback the callback to execute after the view has faded out
 */
public static void fadeOutIn(final View view, final Handler.Callback callback) {
    final Animation in = new AlphaAnimation(0.0f, 1.0f);
    in.setDuration(ANIMATION_SPEED);
    final Animation out = new AlphaAnimation(1.0f, 0.0f);
    out.setDuration(ANIMATION_SPEED);
    out.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            callback.handleMessage(null);
            view.startAnimation(in);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    view.startAnimation(out);
}

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);

    AnimationSet animationSet = new AnimationSet(true);
    // animationSet.setInterpolator(new AccelerateInterpolator());
    animationSet.addAnimation(animation);
    return animationSet;
}

From source file:Main.java

public static void fadeIn(final View view, AnimationListener animationListener, int duration) {
    Animation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setAnimationListener(animationListener);
    view.startAnimation(alphaAnimation);
}

From source file:Main.java

public static void fadeOut(final View view, AnimationListener animationListener, int duration) {
    view.setVisibility(View.VISIBLE);
    Animation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setAnimationListener(animationListener);
    view.startAnimation(alphaAnimation);
}

From source file:Main.java

public static void fadeAnimation(final View view, final float fromAlpha, final float toAlpha, long duration,
        final Runnable callback) {
    Animation anim = new AlphaAnimation(fromAlpha, toAlpha);
    anim.setDuration(duration);
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override/*from w  ww.j a  v  a  2s  .  c  om*/
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.setAlpha(toAlpha);
            if (toAlpha > 0)
                view.setVisibility(View.VISIBLE);
            else
                view.setVisibility(View.GONE);

            if (callback != null)
                callback.run();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    view.setVisibility(View.VISIBLE);
    view.startAnimation(anim);
}

From source file:Main.java

public static void animaBotao(Button botao) {
    final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    animation.setDuration(400);
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(2);//  w  w w . j  a  v a  2 s.com
    animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in
    botao.startAnimation(animation);
}