get Alpha Animator - Android android.animation

Android examples for android.animation:Animator

Description

get Alpha Animator

Demo Code


//package com.java2s;
import android.animation.Animator;

import android.animation.ObjectAnimator;
import android.view.View;

public class Main {
    public static Animator getAlphaAnimator(View view) {
        return getAlphaAnimator(view, false);
    }//from  w ww . j a v a  2s  . c o m

    public static Animator getAlphaAnimator(View view, boolean hideView) {
        float start = hideView ? 1 : 0;
        float end = hideView ? 0 : 1;
        view.setAlpha(start);
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA,
                start, end);
        animator.setDuration(200);
        return animator;
    }
}

Related Tutorials