Android examples for Animation:Scale Animation
scale Hide
//package com.java2s; 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 scaleHide(final View view) { scaleHide(view, null);//from w w w . j a va 2 s .c o m } public static void scaleHide(final View view, final Runnable rWhenEnd) { scaleHide(view, DURATION_SHORT, rWhenEnd); } public static void scaleHide(final View view, long duration, final Runnable rWhenEnd) { if (view.getWindowToken() == null) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } return; } ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0f); AnimatorSet set = new AnimatorSet(); set.playTogether(scaleX, scaleY); set.setDuration(duration); set.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationCancel(Animator animation) { view.setVisibility(View.INVISIBLE); if (rWhenEnd != null) { rWhenEnd.run(); } } @Override public void onAnimationRepeat(Animator animation) { } }); set.start(); } }