Example usage for android.view View ALPHA

List of usage examples for android.view View ALPHA

Introduction

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

Prototype

Property ALPHA

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

Click Source Link

Document

A Property wrapper around the alpha functionality handled by the View#setAlpha(float) and View#getAlpha() methods.

Usage

From source file:Main.java

public static ObjectAnimator createShowGradientAnimation(View view) {
    ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1f);
    alphaAnimation.setDuration(400);//w  w w.  java 2  s  .  c om
    alphaAnimation.setInterpolator(new LinearInterpolator());
    return alphaAnimation;
}

From source file:Main.java

public static ObjectAnimator alphaIn(View view) {
    PropertyValuesHolder pvhAlpha = PropertyValuesHolder.ofKeyframe(View.ALPHA, Keyframe.ofFloat(0f, 0f),
            Keyframe.ofFloat(1f, 1f));/*www.jav a 2 s.c om*/

    return ObjectAnimator.ofPropertyValuesHolder(view, pvhAlpha).setDuration(300);
}

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);/*from   w  ww . jav  a  2s  .co m*/
    ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, start, end);
    animator.setDuration(200);
    return animator;
}

From source file:Main.java

@NonNull
private static AnimatorSet createRevealAnimation(View headline, View btnPanel, View recyclerView,
        View locationTxt) {/*from  www .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

@NonNull
private static AnimatorSet createDisappearAnim(View btnPanel, View recyclerView, View locationTxt,
        View headline) {/*  w  w  w . java  2s.  c o m*/
    AnimatorSet animAll = new AnimatorSet();

    Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0);
    Animator anim1_2 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0);
    Animator anim1_3 = ObjectAnimator.ofFloat(btnPanel, View.ALPHA, 1, 0);
    Animator anim1_4 = ObjectAnimator.ofFloat(recyclerView, View.ALPHA, 1, 0);
    setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_4);
    animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4);

    Interpolator interpolator2 = new DecelerateInterpolator();
    Animator anim2_1 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 1, 0);
    Animator anim2_2 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_X, 1f, 2f);
    Animator anim2_3 = ObjectAnimator.ofFloat(locationTxt, View.SCALE_Y, 1f, 2f);
    anim2_1.setInterpolator(interpolator2);
    anim2_2.setInterpolator(interpolator2);
    anim2_3.setInterpolator(interpolator2);
    setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3);
    animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1);
    return animAll;
}

From source file:Main.java

public static ValueAnimator getAlphaAnimator(View view, float... values) {
    return ObjectAnimator.ofFloat(view, View.ALPHA, values);
}

From source file:Main.java

public static void breath(View v, float fromRange, float toRange, long duration) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.ALPHA, fromRange, toRange);
    animator.setDuration(duration);//w  ww.j  ava2  s .  c o m
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(ValueAnimator.INFINITE);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.start();
}

From source file:Main.java

public static ObjectAnimator to_alpha(View target) {

    ObjectAnimator objectAnimator = null;
    if (null != target && target.getVisibility() != View.VISIBLE) {
        target.setVisibility(View.VISIBLE);

        objectAnimator = ObjectAnimator.ofFloat(target, View.ALPHA, 0f, 1f)
                .setDuration(BUBBLE_ANIMATION_DURATION);

        objectAnimator.start();//from w w w  .  j a  v  a 2 s . c o m
    }

    return objectAnimator;
}

From source file:Main.java

public static ObjectAnimator alpha_to(final View target) {

    ObjectAnimator objectAnimator = null;

    if (null != target) {
        objectAnimator = ObjectAnimator.ofFloat(target, View.ALPHA, 1f, 0f)
                .setDuration(BUBBLE_ANIMATION_DURATION);

        objectAnimator.addListener(new AnimatorListenerAdapter() {
            @Override/*from   w w  w . j a  v  a2  s . c  om*/
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                target.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                target.setVisibility(View.GONE);
            }
        });

        objectAnimator.start();
    }

    return objectAnimator;
}

From source file:Main.java

/**
 * alpha//w w w  .  j a v  a2  s.  c  o m
 *
 * @param v
 * @param fromAlpha
 * @param toAlpha
 * @param duration
 * @param animatorListener
 */
public static void alpha(View v, float fromAlpha, float toAlpha, int duration,
        Animator.AnimatorListener animatorListener) {
    ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.ALPHA, fromAlpha, toAlpha);
    animator.setDuration(duration);
    if (animatorListener != null) {
        animator.addListener(animatorListener);
    }
    animator.start();
}