fade In View with Animation - Android android.view.animation

Android examples for android.view.animation:Fade Animation

Description

fade In View with Animation

Demo Code

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

public class Main {

  public static void fadeIn(View view, float startAlpha, float endAlpha, long duration) {
    if (view.getVisibility() == View.VISIBLE)
      return;/* w ww .  j  av  a2 s .c  om*/

    view.setVisibility(View.VISIBLE);
    Animation animation = new AlphaAnimation(startAlpha, endAlpha);
    animation.setDuration(duration);
    view.startAnimation(animation);
  }

  public static void fadeIn(View view) {
    fadeIn(view, 0F, 1F, 400);

    // We disabled the button in fadeOut(), so enable it here.
    view.setEnabled(true);
  }
  
}

Related Tutorials