Android examples for Animation:Fade Animation
Hide the provided View with a fade-out animation.
//package com.java2s; import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewPropertyAnimatorListener; import android.view.View; public class Main { public static final int ANIMATION_DURATION_SHORTEST = 150; public static void fadeOutView(View view) { fadeOutView(view, ANIMATION_DURATION_SHORTEST); }// w ww .java2 s.c om public static void fadeOutView(final View view, int duration) { ViewCompat.animate(view).alpha(0f).setDuration(duration) .setListener(new ViewPropertyAnimatorListener() { @Override public void onAnimationStart(View view) { view.setDrawingCacheEnabled(true); } @Override public void onAnimationEnd(View view) { view.setVisibility(View.GONE); view.setAlpha(1f); view.setDrawingCacheEnabled(false); } @Override public void onAnimationCancel(View view) { } }); } }