Fades the specified view in. - Android User Interface

Android examples for User Interface:View Fade

Description

Fades the specified view in.

Demo Code


//package com.java2s;

import android.view.View;

import android.view.animation.AlphaAnimation;

public class Main {
    /**//w  w w .  j a v  a  2s  .  co  m
     * Fades the specified view in.
     * 
     * @param v
     *            the view to fade in
     */
    public static void fadeIn(View v) {
        showView(v);
        AlphaAnimation fadeIn = new AlphaAnimation(0F, 1F);
        fadeIn.setDuration(1000);
        fadeIn.setFillAfter(false);
        v.startAnimation(fadeIn);

    }

    /**
     * Shows the specified view if invisible or gone.
     * 
     * @param v
     *            the view to show
     */
    public static void showView(View v) {
        if (v.getVisibility() == View.INVISIBLE
                || v.getVisibility() == View.GONE) {
            v.setVisibility(View.VISIBLE);
        }
    }
}

Related Tutorials