get Appearing Expanding Animation Set - Android Animation

Android examples for Animation:Expand Animation

Description

get Appearing Expanding Animation Set

Demo Code


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

import android.support.annotation.NonNull;

import android.view.View;

public class Main {
    @NonNull//w ww .  ja v  a  2 s .  com
    public static AnimatorSet getAppearingExpandingSet(View view,
            long duration) {
        view.setAlpha(0f);

        final ObjectAnimator visibilityAnim = ObjectAnimator.ofFloat(view,
                "alpha", 0f, 1f);
        visibilityAnim.setDuration(duration);

        final ObjectAnimator xScaleAnim = ObjectAnimator.ofFloat(view,
                "scaleX", 0f, 1f);
        xScaleAnim.setDuration(duration);

        final ObjectAnimator yScaleAnim = ObjectAnimator.ofFloat(view,
                "scaleY", 0f, 1f);
        yScaleAnim.setDuration(duration);

        final AnimatorSet appearingSet = new AnimatorSet();
        appearingSet.play(visibilityAnim).with(xScaleAnim).with(yScaleAnim);
        return appearingSet;
    }
}

Related Tutorials