show View using animation and duration - Android User Interface

Android examples for User Interface:View Hide Show

Description

show View using animation and duration

Demo Code

/*/*from   w w  w  .ja  v a 2s .co m*/
 * *
 *  * Copyright 2012 fenbi.com. All rights reserved.
 *  * FENBI.COM PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 */
//package com.java2s;

import android.view.View;

import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;

public class Main {
    private static long ANIMATE_DURATION = 200;

    public static View showView(View v, boolean animate, long duration) {
        if (v != null) {
            v.setVisibility(View.VISIBLE);
            if (animate) {
                Animation ani = new AlphaAnimation(0f, 1f);
                ani.setDuration(duration);
                v.startAnimation(ani);
            }
        }
        return v;
    }

    public static View showView(View v, boolean animate) {
        return showView(v, animate, ANIMATE_DURATION);
    }
}

Related Tutorials