Java tutorial
//package com.java2s; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.view.View; public class Main { /** * Fade in or fade out a given view. */ public static void animateViewSetVisible(final boolean visible, final View view) { view.setVisibility(View.VISIBLE); view.setAlpha(visible ? 0 : 1); view.animate().setDuration(300).alpha(visible ? 1 : 0).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(visible ? View.VISIBLE : View.GONE); } }); } }