Java tutorial
//package com.java2s; //License from project: Apache License import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.view.View; public class Main { public static final int DURATION_SHORT = 300; public static void scaleShow(final View view) { scaleShow(view, null); } public static void scaleShow(final View view, final Runnable rWhenEnd) { if (view.getVisibility() == View.VISIBLE) { view.setVisibility(View.VISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } return; } if (view.getWindowToken() == null) { view.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { scaleShow(view); } @Override public void onViewDetachedFromWindow(View v) { } }); } ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f); AnimatorSet set = new AnimatorSet(); set.playTogether(scaleX, scaleY); set.setDuration(DURATION_SHORT); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.VISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.VISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); } }