post Animation Bottom - Android android.animation

Android examples for android.animation:Animation

Description

post Animation Bottom

Demo Code


//package com.java2s;

import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;

import android.view.animation.TranslateAnimation;

public class Main {
    public static void postAnimationBottom(final View childLayout,
            int delay, final int duration) {
        int visibility = childLayout.getVisibility();
        if (visibility != View.VISIBLE) {
            return;
        }//from  w ww.ja v  a2s.c o  m
        childLayout.setVisibility(View.INVISIBLE);
        childLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                childLayout.setVisibility(View.VISIBLE);
                AnimationSet animationSet = new AnimationSet(true);
                animationSet.setDuration(duration);
                animationSet
                        .setInterpolator(new AccelerateDecelerateInterpolator());
                int pivotXType = Animation.RELATIVE_TO_SELF;
                animationSet.addAnimation(new TranslateAnimation(
                        pivotXType, 0, pivotXType, 0, pivotXType, 1,
                        pivotXType, 0));
                animationSet.addAnimation(new AlphaAnimation(0, 1));
                childLayout.startAnimation(animationSet);
            }
        }, delay);
    }
}

Related Tutorials