Example usage for android.animation ObjectAnimator setDuration

List of usage examples for android.animation ObjectAnimator setDuration

Introduction

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

Prototype

@Override
@NonNull
public ObjectAnimator setDuration(long duration) 

Source Link

Document

Sets the length of the animation.

Usage

From source file:Main.java

public static ObjectAnimator fadeIn(final View v) {
    ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(v, "alpha", 0f, 1f);
    alphaAnim.setDuration(ANIM_DURATION_FADEIN);
    alphaAnim.addListener(new AnimatorListenerAdapter() {
        @Override//www  .  j  ava2s . c  o  m
        public void onAnimationStart(Animator animation) {
            v.setVisibility(View.VISIBLE);
        }
    });

    return alphaAnim;
}

From source file:Main.java

public static void rotateWithDuration(View view, int milliseconds, int radiusFrom, int radiusTo) {
    ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotation", radiusFrom, radiusTo);
    animation.setDuration(milliseconds);
    animation.start();/* w  w  w  . j  a v  a 2s . co  m*/
}

From source file:Main.java

public static Animator getAlphaAnimator(View view, boolean hideView) {
    float start = hideView ? 1 : 0;
    float end = hideView ? 0 : 1;
    view.setAlpha(start);// www.j  a v  a2  s .  c o  m
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, start, end);
    animator.setDuration(200);
    return animator;
}

From source file:Main.java

public static void animation3(View view) {
    ObjectAnimator animator = new ObjectAnimator().ofFloat(view, "rotationY", 0.0f, 360f);
    animator.setDuration(4000);
    animator.setRepeatCount(2);/*from   w  ww.j av a 2 s .  co  m*/
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:Main.java

public static ObjectAnimator tranY(View view, int duration, float pos) {
    float currentY = view.getTranslationY();
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, TRANSLATION_Y, pos, currentY);
    return animator.setDuration(duration);
}

From source file:Main.java

public static void slowViewAnimation(View view) {
    ObjectAnimator translationY = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, -200f, 0f);
    translationY.setDuration(5000);
    AnimatorSet translateSlowly = new AnimatorSet();
    translateSlowly.playTogether(translationY);
    translateSlowly.start();/*  w w w. j  a v  a2  s  . c  o m*/
}

From source file:Main.java

public static ObjectAnimator rotate(View view, float startDegree, float endDegree, int duration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotation", startDegree, endDegree);
    animator.setDuration(duration);
    animator.setRepeatCount(-1);//from   w  w  w .  j av  a2s  .c  o  m
    animator.start();
    return animator;
}

From source file:Main.java

public static void backgroundToWhite(View view) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", 0xffbdbdbd, 0xffffffff);
    animator.setDuration(1);
    animator.start();/*from   ww w.  j  a  v  a  2s.c  o m*/
}

From source file:Main.java

public static void backgroundToGrey(View view) {
    ObjectAnimator animator = ObjectAnimator.ofInt(view, "backgroundColor", 0xffffffff, 0xffbdbdbd);
    animator.setDuration(1);
    animator.start();//from  ww w  .j  av a2 s . co  m
}

From source file:Main.java

/**
 * Fade Animation//from   ww w .j  a v a2  s.co m
 * @param view View to be animated
 * @param fromAlpha initial alpha
 * @param toAlpha final alpha
 * @param duration animation duration in milliseconds
 * @return Animator Object
 */
@NonNull
public static Animator fade(@NonNull final View view, float fromAlpha, float toAlpha, int duration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", fromAlpha, toAlpha);
    animator.setDuration(duration);
    return animator;
}