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

/**
 * @return A fade out animation from 100% - 0% taking half a second
 *///w w  w .  jav  a2  s  .  c  o  m
public static Animation createFadeoutAnimation() {
    Animation fadeout = new AlphaAnimation(VISIBLE, INVISIBLE);
    fadeout.setDuration(HALF_A_SECOND);
    return fadeout;
}

From source file:Main.java

public static Animation getAlphaAnimation(float fromAlpha, float toAlpha, long durationMillis) {
    Animation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
    alphaAnimation.setDuration(durationMillis);
    return alphaAnimation;
}

From source file:Main.java

public static Animation translateAnimation(int fromX, int toX, int fromY, int toY) {
    Animation animation = new TranslateAnimation(fromX, toX, fromY, toY);
    animation.setDuration(400);
    return animation;
}

From source file:Main.java

public static void startTranslateAnim(View view, float fromX, float toX, float fromY, float toY,
        long duration) {
    Animation anim = new TranslateAnimation(fromX, toX, fromY, toY);
    anim.setDuration(duration);
    anim.setFillAfter(true);//from w w  w  .  j ava2s.c  o m
    view.startAnimation(anim);
}

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);
    set.addAnimation(animation);//from  w w w  .  j  a  va  2 s .c  om
    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 fadeOut(View view) {
    if (view.getVisibility() != View.VISIBLE)
        return;//from   w  w w. j  a  va2s.co m

    Animation animation = new AlphaAnimation(1F, 0F);
    animation.setDuration(400);
    view.startAnimation(animation);
    view.setVisibility(View.GONE);
}

From source file:Main.java

public static void performScaleWithCustomTime(int i, View view, Context context) {
    Animation animation = AnimationUtils.loadAnimation(context, 0x7f04000c);
    animation.setDuration(i);
    view.startAnimation(animation);//from  w w w  .  ja  v a 2  s  .  c  om
}

From source file:Main.java

public static void fadeIn(View view) {
    if (view.getVisibility() == View.VISIBLE)
        return;//  ww  w .  j a  v  a2 s  .  co  m

    view.setVisibility(View.VISIBLE);
    Animation animation = new AlphaAnimation(0F, 1F);
    animation.setDuration(400);
    view.startAnimation(animation);
}

From source file:Main.java

public static void performScaleXWithCustomTime(int i, View view, Context context) {
    Animation animation = AnimationUtils.loadAnimation(context, 0x7f04000d);
    animation.setDuration(i);
    view.startAnimation(animation);//from   w  ww  .jav a2 s.  com
}

From source file:Main.java

public static void performAlphaAnimationWithCustomTime(int i, View view, Context context) {
    Animation animation = AnimationUtils.loadAnimation(context, 0x7f040008);
    animation.setDuration(i);
    view.startAnimation(animation);//from  w  w w  .j  a  va 2  s  .c  o  m
}