Shows the view by having it fade in. - Android User Interface

Android examples for User Interface:View Fade

Description

Shows the view by having it fade in.

Demo Code


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

public class Main {
    /**/*w ww .ja  va2 s.co m*/
     * Shows the view by having it fade in.
     * @param view - the view.
     */
    public static void showView(final View view, int duration) {
        AlphaAnimation fade_in = new AlphaAnimation(0.0f, 1.0f);
        fade_in.setDuration(duration);
        fade_in.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                view.setVisibility(View.VISIBLE);
            }

            public void onAnimationRepeat(Animation animation) {
            }

            public void onAnimationEnd(Animation animation) {
            }
        });
        view.startAnimation(fade_in);
    }
}

Related Tutorials