grow View animation - Android User Interface

Android examples for User Interface:View Animation

Description

grow View animation

Demo Code


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

import android.animation.ValueAnimator;

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

public class Main {
    public static void grow(final View v, int growTime,
            @Nullable Animator.AnimatorListener listener) {
        v.setVisibility(View.VISIBLE);
        v.bringToFront();/* w  ww  .  j  ava 2  s .  co m*/
        ValueAnimator a = ValueAnimator.ofFloat(0f, 1f);
        a.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                v.setScaleX((Float) animation.getAnimatedValue());
                v.setScaleY((Float) animation.getAnimatedValue());
            }
        });
        a.setDuration(growTime);
        if (listener != null)
            a.addListener(listener);
        a.start();
    }
}

Related Tutorials