Create Fade Animation ObjectAnimatorwith - Android Animation

Android examples for Animation:Fade Animation

Description

Create Fade Animation ObjectAnimatorwith

Demo Code


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

import android.support.annotation.NonNull;
import android.view.View;

public class Main {
    /**//from  w  w w .j av a2  s. c  o  m
     * Fade Animation
     * @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;
    }
}

Related Tutorials