Example usage for android.view View SCALE_Y

List of usage examples for android.view View SCALE_Y

Introduction

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

Prototype

Property SCALE_Y

To view the source code for android.view View SCALE_Y.

Click Source Link

Document

A Property wrapper around the scaleY functionality handled by the View#setScaleY(float) and View#getScaleY() methods.

Usage

From source file:Main.java

public static ObjectAnimator createScaleYAnimator(View view, float from, float to) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.SCALE_Y, from, to);
    return animator;
}

From source file:Main.java

public static AnimatorSet getScaleAnimator(View view, float startScale, float endScale) {
    AnimatorSet set = new AnimatorSet();
    ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(view, View.SCALE_X, startScale, endScale);
    ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(view, View.SCALE_Y, startScale, endScale);
    set.playTogether(scaleXAnimator, scaleYAnimator);
    return set;//from ww w .j a  va  2 s .  c  om
}

From source file:Main.java

public static void animateScaleIn(View view, long duration, Animator.AnimatorListener listener) {
    view.setScaleX(0f);//from w  w  w.j  a v  a 2  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

@NonNull
private static AnimatorSet createRevealAnimation(View headline, View btnPanel, View recyclerView,
        View locationTxt) {/*from  w  ww. j  a  v a  2  s  . c o  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 ObjectAnimator tada(View view, float shakeFactor) {

    PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f),
            Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f),
            Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f),
            Keyframe.ofFloat(1f, 1f));/* w ww  .  j  ava 2 s .c  o  m*/

    PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f),
            Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f),
            Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f),
            Keyframe.ofFloat(1f, 1f));

    PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f),
            Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor),
            Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor),
            Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor),
            Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor),
            Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0));

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1000);
}

From source file:Main.java

public static ValueAnimator getScaleAnimator(View view, float... values) {
    return ObjectAnimator.ofPropertyValuesHolder(view, PropertyValuesHolder.ofFloat(View.SCALE_X, values),
            PropertyValuesHolder.ofFloat(View.SCALE_Y, values));
}

From source file:Main.java

public static synchronized void animateScaleUp(View v, float targetScale) {
    float currentScaleX = v.getScaleX();
    float currentScaleY = v.getScaleY();

    PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofFloat(View.SCALE_X, currentScaleX, targetScale);
    PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofFloat(View.SCALE_Y, currentScaleY, targetScale);
    ValueAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(v, scaleXHolder, scaleYHolder);
    scaleAnimator.start();//www .  j av a  2s .  c o m
}

From source file:Main.java

public static synchronized void animateScaleDown(View v, float targetScale) {
    float currentScaleX = v.getScaleX();
    float currentScaleY = v.getScaleY();

    PropertyValuesHolder scaleXHolder = PropertyValuesHolder.ofFloat(View.SCALE_X, currentScaleX, targetScale);
    PropertyValuesHolder scaleYHolder = PropertyValuesHolder.ofFloat(View.SCALE_Y, currentScaleY, targetScale);

    ValueAnimator scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(v, scaleXHolder, scaleYHolder);
    scaleAnimator.start();/* w  ww .ja  va 2s  . c  o  m*/
}

From source file:Main.java

/**
 * Shake the view for whole direction/*from   w w w.java  2  s  .c  o m*/
 *
 * @param view
 * @param shakeFactor
 * @return
 */
public static ObjectAnimator wholeShake(View view, float shakeFactor) {

    PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f),
            Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f),
            Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f),
            Keyframe.ofFloat(1f, 1f));

    PropertyValuesHolder pvhScaleY = PropertyValuesHolder.ofKeyframe(View.SCALE_Y, Keyframe.ofFloat(0f, 1f),
            Keyframe.ofFloat(.1f, .9f), Keyframe.ofFloat(.2f, .9f), Keyframe.ofFloat(.3f, 1.1f),
            Keyframe.ofFloat(.4f, 1.1f), Keyframe.ofFloat(.5f, 1.1f), Keyframe.ofFloat(.6f, 1.1f),
            Keyframe.ofFloat(.7f, 1.1f), Keyframe.ofFloat(.8f, 1.1f), Keyframe.ofFloat(.9f, 1.1f),
            Keyframe.ofFloat(1f, 1f));

    PropertyValuesHolder pvhRotate = PropertyValuesHolder.ofKeyframe(View.ROTATION, Keyframe.ofFloat(0f, 0f),
            Keyframe.ofFloat(.1f, -3f * shakeFactor), Keyframe.ofFloat(.2f, -3f * shakeFactor),
            Keyframe.ofFloat(.3f, 3f * shakeFactor), Keyframe.ofFloat(.4f, -3f * shakeFactor),
            Keyframe.ofFloat(.5f, 3f * shakeFactor), Keyframe.ofFloat(.6f, -3f * shakeFactor),
            Keyframe.ofFloat(.7f, 3f * shakeFactor), Keyframe.ofFloat(.8f, -3f * shakeFactor),
            Keyframe.ofFloat(.9f, 3f * shakeFactor), Keyframe.ofFloat(1f, 0));

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).setDuration(1000);
}

From source file:Main.java

/**
 * scale y//w  w w.ja va2s. c  o  m
 *
 * @param v
 * @param fromY
 * @param toY
 * @param duration
 * @param animatorListener
 */
public static void scaleY(View v, float fromY, float toY, int duration,
        Animator.AnimatorListener animatorListener) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.SCALE_Y, fromY, toY);
    animator.setDuration(duration);
    if (animatorListener != null) {
        animator.addListener(animatorListener);
    }
    animator.start();
}