Hides the view by having it fade away. - Android User Interface

Android examples for User Interface:View Fade

Description

Hides the view by having it fade away.

Demo Code


//package com.java2s;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

public class Main {
    /**/*from  w  w w .  jav a  2 s . co m*/
     * Hides the view by having it fade away.
     * @param view - the view.
     */
    public static void hideView(final View view, int duration) {
        AlphaAnimation fade_out = new AlphaAnimation(1.0f, 0.0f);
        fade_out.setDuration(duration);
        fade_out.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation arg0) {
            }

            public void onAnimationRepeat(Animation arg0) {
            }

            public void onAnimationEnd(Animation arg0) {
                view.setVisibility(View.GONE);
            }
        });
        view.startAnimation(fade_out);
    }
}

Related Tutorials