Example usage for android.animation AnimatorSet AnimatorSet

List of usage examples for android.animation AnimatorSet AnimatorSet

Introduction

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

Prototype

public AnimatorSet() 

Source Link

Usage

From source file:Main.java

public static void animateSpinIn(View view, long duration, Animator.AnimatorListener listener) {
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setDuration(duration);//from   w ww .j a  va 2s. co  m
    animatorSet.playTogether(ObjectAnimator.ofFloat(view, "rotation", -200, 0),
            ObjectAnimator.ofFloat(view, "alpha", 0, 1));
    animatorSet.start();
}

From source file:Main.java

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

From source file:Main.java

public static void makeClick(View v) {
    ObjectAnimator clickX = ObjectAnimator.ofFloat(v, "scaleX", 1, 0.7f, 1).setDuration(100);
    ObjectAnimator clickY = ObjectAnimator.ofFloat(v, "scaleY", 1, 0.7f, 1).setDuration(100);
    AnimatorSet click = new AnimatorSet();
    click.playTogether(clickX, clickY);//  ww w . j  av a2 s . c o m
    click.start();
}

From source file:Main.java

private static void initAnim() {

    animatorSet = new AnimatorSet();
    animatorSet.setDuration(500);//from  ww w .jav a 2 s  .  c o m

    ObjectAnimator x = ObjectAnimator.ofFloat(text, "scaleX", 0.3f, 1f);
    ObjectAnimator y = ObjectAnimator.ofFloat(text, "scaleY", 0.3f, 1f);
    ObjectAnimator a = ObjectAnimator.ofFloat(text, "alpha", 0.3f, 1f);

    animatorSet.play(x).with(y).with(a);
    animatorSet.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            isAiming = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            isAiming = false;
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            isAiming = false;
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
            isAiming = true;
        }
    });
}

From source file:Main.java

public static void runFlipHorizonAnimation(@NonNull View view, long duration, final Runnable rWhenEnd) {
    view.setAlpha(0);//from  w ww  .j a v  a  2  s .  co m
    AnimatorSet set = new AnimatorSet();
    ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(view, "rotationY", -180f, 0f);
    ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
    set.setDuration(duration);
    set.playTogether(objectAnimator1, objectAnimator2);
    if (rWhenEnd != null)
        set.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                rWhenEnd.run();
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
    set.start();
}

From source file:Main.java

public static void changeImageSize(ImageView image, float fromScale, float toScale) {
    ObjectAnimator scaleX;//w w  w. ja  v  a 2s .  c  om
    ObjectAnimator scaleY;
    scaleX = ObjectAnimator.ofFloat(image, "scaleX", fromScale, toScale);
    scaleY = ObjectAnimator.ofFloat(image, "scaleY", fromScale, toScale);
    AnimatorSet set = new AnimatorSet();
    set.setDuration(150);
    set.playTogether(scaleX, scaleY);
    set.start();
}

From source file:Main.java

@NonNull
private static AnimatorSet createRevealAnimation(View headline, View btnPanel, View recyclerView,
        View locationTxt) {// ww  w .  j a  v a  2  s . co m
    AnimatorSet animAll = new AnimatorSet();

    Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 0, 1, 1);
    Animator anim1_2 = ObjectAnimator.ofFloat(headline, View.TRANSLATION_Y, -headline.getBottom(), 60, 0);
    Animator anim1_3 = ObjectAnimator.ofFloat(headline, View.SCALE_X, 0.1f, 0.475f, 1);
    Animator anim1_4 = ObjectAnimator.ofFloat(headline, View.SCALE_Y, 0.1f, 0.475f, 1);
    setBatchTiming(1000, 0, anim1_1, anim1_2, anim1_3, anim1_4);
    animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4);

    Animator anim2_1 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 0, 1);
    Animator anim2_2 = ObjectAnimator.ofFloat(btnPanel, View.TRANSLATION_Y, btnPanel.getHeight() / 4, 0);
    setBatchTiming(800, 0, anim2_1, anim2_2);
    animAll.play(anim2_1).with(anim2_2).after(anim1_1);

    Animator anim3_1 = ObjectAnimator.ofFloat(recyclerView, View.ALPHA, 0, 1);
    Animator anim3_2 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 0, 1);
    setBatchTiming(1800, 0, anim3_1, anim3_2);
    animAll.play(anim3_1).with(anim3_2).after(anim1_1);
    return animAll;
}

From source file:Main.java

public static void animateScaleIn(View view, long duration, Animator.AnimatorListener listener) {
    view.setScaleX(0f);// w  ww .j a v a2  s  .  c  o m
    view.setScaleY(0f);
    view.setVisibility(View.VISIBLE);

    AnimatorSet scaleSet = new AnimatorSet();
    scaleSet.playTogether(ObjectAnimator.ofFloat(view, View.SCALE_X, 1f),
            ObjectAnimator.ofFloat(view, View.SCALE_Y, 1f));
    scaleSet.setInterpolator(new AccelerateDecelerateInterpolator());
    scaleSet.setDuration(duration);
    if (listener != null) {
        scaleSet.addListener(listener);
    }
    scaleSet.start();
    //return scaleSet;
}

From source file:Main.java

public static void animateHeart(View view) {
    AnimatorSet animatorSet = new AnimatorSet();
    ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.2f);
    imgScaleUpYAnim.setDuration(300);/*  ww w.  j  av a  2 s.c  om*/
    ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, 1.2f);
    imgScaleUpXAnim.setDuration(300);
    ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(view, "scaleY", 1.2f, 1.0f);
    imgScaleDownYAnim.setDuration(300);
    imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(view, "scaleX", 1.2f, 1.0f);
    imgScaleDownXAnim.setDuration(300);
    animatorSet.playTogether(imgScaleUpXAnim, imgScaleUpYAnim);
    animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpXAnim);
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            view.clearAnimation();
            animatorSet.start();
        }
    });
    animatorSet.start();
}

From source file:Main.java

public static void animateColorChange(View view, int fromColor, int toColor, int duration,
        Animator.AnimatorListener listener) {
    if (view.getWindowToken() == null) {
        return;//from   w  w  w  .j av a  2s .  c  om
    }
    AnimatorSet animation = new AnimatorSet();
    ObjectAnimator colorAnimator = ObjectAnimator.ofInt(view, COLOR_PROPERTY, fromColor, toColor);
    colorAnimator.setEvaluator(new ArgbEvaluator());
    colorAnimator.setDuration(duration);
    if (listener != null)
        animation.addListener(listener);
    animation.play(colorAnimator);
    animation.start();
}