Fades a view in - Android User Interface

Android examples for User Interface:View Fade

Description

Fades a view in

Demo Code


//package com.java2s;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;

import android.view.View;

public class Main {
    /**/*from  w ww. j a  v  a  2 s . co  m*/
     * Fades a view in
     *
     * @param in view being faded in
     */
    public static final void fadeIn(final View in, Context context) {
        int shortAnimTime = context.getResources().getInteger(
                android.R.integer.config_shortAnimTime);
        in.setVisibility(View.VISIBLE);
        in.animate().setDuration(shortAnimTime).alpha(1f)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        in.setVisibility(View.VISIBLE);
                    }
                });
    }
}

Related Tutorials