fade Out View with AlphaAnimation - Android android.view.animation

Android examples for android.view.animation:Fade Animation

Description

fade Out View with AlphaAnimation

Demo Code

import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

public class Main {

  public static void fadeOut(View view) {
    if (view.getVisibility() != View.VISIBLE)
      return;/*from  w  w  w  .ja  va2  s  .  c o m*/

    // Since the button is still clickable before fade-out animation
    // ends, we disable the button first to block click.
    view.setEnabled(false);
    Animation animation = new AlphaAnimation(1F, 0F);
    animation.setDuration(400);
    view.startAnimation(animation);
    view.setVisibility(View.GONE);
  }

}

Related Tutorials