Example usage for android.view View startAnimation

List of usage examples for android.view View startAnimation

Introduction

In this page you can find the example usage for android.view View startAnimation.

Prototype

public void startAnimation(Animation animation) 

Source Link

Document

Start the specified animation now.

Usage

From source file:Main.java

public static void rotate180to360(View view) {
    RotateAnimation rotate = new RotateAnimation(180, 360, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    rotate.setDuration(ANIM);/*from w w w  . j a v  a 2  s  .  c  om*/
    rotate.setInterpolator(new LinearInterpolator());
    rotate.setFillAfter(true);
    view.startAnimation(rotate);
}

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);// w  w  w.j  a  va2 s . co m
    anim.setFillAfter(true);
    view.startAnimation(anim);
}

From source file:Main.java

public static void rotateAnimation(View view, float fromDegree, float toDegree) {
    final RotateAnimation rotateAnim = new RotateAnimation(fromDegree, toDegree,
            RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);

    rotateAnim.setDuration(200);//  w  ww.  j  av  a  2s  . c o m
    rotateAnim.setFillAfter(true);
    view.startAnimation(rotateAnim);
}

From source file:Main.java

public static void startCollapseViewAnimationOn(final View expandableContainer) {
    if (expandableContainer.getVisibility() == View.VISIBLE) {
        Animation animation = getCollapseViewAnimation(expandableContainer, EXPAND_OR_COLLAPSE_DURATION);
        expandableContainer.startAnimation(animation);
    }// w w  w.j  a  v  a2 s. c  o m
}

From source file:Main.java

public static void animateView(View view) {
    final Animation animation = new AlphaAnimation(1f, 0f);
    animation.setDuration(1000); // Animate for 1 seconds
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    view.startAnimation(animation);
}

From source file:Main.java

public static void startExpandViewAnimationOn(final View expandableContainer) {
    if (expandableContainer.getVisibility() != View.VISIBLE) {
        Animation animation = getExpandViewAnimation(expandableContainer, EXPAND_OR_COLLAPSE_DURATION);
        expandableContainer.startAnimation(animation);
    }//w  ww .j  ava 2 s  .  c o  m
}

From source file:Main.java

public static void alphaAnimation(View v, float fromAlpha, float toAlpha, long durationMillis,
        boolean fillAfter) {
    AlphaAnimation animation = new AlphaAnimation(fromAlpha, toAlpha);
    animation.setDuration(durationMillis);
    animation.setFillAfter(fillAfter);//from   ww  w . ja  v  a2 s  .c o  m
    animation.setRepeatMode(Animation.REVERSE);
    v.startAnimation(animation);
}

From source file:Main.java

/**
 * Animate a view to fade in./* ww  w  .ja  v  a  2 s. c  o m*/
 *
 * @param view         The view to be animated.
 * @param duration     Duration that the animation should run, in milliseconds; specify -1 to use the default.
 * @param interpolator The interpolator which defines the acceleration curve; can be null to use default.
 */
public static void startFadeIn(View view, long duration, Interpolator interpolator) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
    if (duration > 0) {
        alphaAnimation.setDuration(duration);
    }
    if (interpolator != null) {
        alphaAnimation.setInterpolator(interpolator);
    }
    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 SlideInRight(View v, final Runnable onComplete) {
    v.clearAnimation();//from  ww  w .  j  av  a2  s . c o  m
    TranslateAnimation aout = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f);
    aout.setDuration(300);
    v.startAnimation(aout);
    if (onComplete != null)
        aout.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation arg0) {
            }

            @Override
            public void onAnimationRepeat(Animation arg0) {
            }

            @Override
            public void onAnimationEnd(Animation arg0) {
                onComplete.run();
            }
        });
}