Android examples for User Interface:View Fade
Fades a view out
//package com.java2s; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.view.View; public class Main { /**//from www . j a va 2s. c o m * Fades a view out * * @param out view being faded out */ public static final void fadeOut(final View out, Context context, int visbilityAfter) { fadeOut(out, context, 0f, visbilityAfter); } /** * Fades a view out * * @param out view being faded out */ public static final void fadeOut(final View out, Context context) { fadeOut(out, context, 0f, View.GONE); } /** * Fades a view out * * @param out view being faded out */ public static final void fadeOut(final View out, Context context, final float toAlpha, final int visbilityAfter) { int shortAnimTime = context.getResources().getInteger( android.R.integer.config_shortAnimTime); out.setVisibility(View.VISIBLE); out.animate().setDuration(shortAnimTime).alpha(toAlpha) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { out.setVisibility(visbilityAfter); } }); } }