animation Slide with TranslateAnimation - Android Animation

Android examples for Animation:Translate Animation

Description

animation Slide with TranslateAnimation

Demo Code


//package com.java2s;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;

public class Main {
    public static Animation animationSlide(int location, int viewSize,
            boolean show) {
        AnimationSet set = new AnimationSet(true);
        Animation animation = new TranslateAnimation(0, 0, 0, 0);
        if (show) {
            animation = new TranslateAnimation(0, 0, viewSize * location, 0);
        } else {/*  w w w  . j  a  v  a  2 s .  co  m*/
            animation = new TranslateAnimation(0, 0, 0, viewSize * location);
        }
        animation.setDuration(200);
        set.addAnimation(animation);
        return animation;
    }
}

Related Tutorials