pop Out View Delayed - Android android.view.animation

Android examples for android.view.animation:Animation

Description

pop Out View Delayed

Demo Code

import android.os.Handler;
import android.view.View;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;

public class Main {

  public static Interpolator OVERSHOOT = new OvershootInterpolator(2.8f);
  public static final int ANIM_DURATION = 300 ;

  public static void popOutViewDelayed(final View view, long delay) {
    new Handler().postDelayed(new Runnable() {
      @Override//from w w  w .  ja  v  a  2 s  . c o  m
      public void run() {
        if (view == null)
          return;

        view.setVisibility(View.VISIBLE);
        view.setScaleY(0f);
        view.setScaleX(0f);

        view.animate().scaleX(1f).scaleY(1f).setInterpolator(OVERSHOOT).setDuration(ANIM_DURATION);
      }
    }, delay);
  }

}

Related Tutorials