animation Translate - Android Animation

Android examples for Animation:Translate Animation

Description

animation Translate

Demo Code


//package com.java2s;
import android.view.View;
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 animationTranslate(View paramView) {
        animation(paramView, new TranslateAnimation(2, 0.0F, 2, 0.0F, 2,
                1.0F, 2, 0.0F), 500L, 0L);
    }//from   www.j a  v a 2 s.c  om

    private static void animation(View paramView, Animation paramAnimation,
            long paramLong1, long paramLong2) {
        paramAnimation.setDuration(paramLong1);
        paramAnimation.setStartOffset(paramLong2);
        paramView.setVisibility(0);
        paramView.startAnimation(paramAnimation);
    }

    public static void animation(View paramView) {
        TranslateAnimation localTranslateAnimation = new TranslateAnimation(
                2, 1.0F, 2, 0.0F, 2, 0.0F, 2, 0.0F);
        AlphaAnimation localAlphaAnimation = new AlphaAnimation(0.0F, 1.0F);
        AnimationSet localAnimationSet = new AnimationSet(false);
        localAnimationSet.addAnimation(localTranslateAnimation);
        localAnimationSet.addAnimation(localAlphaAnimation);
        animation(paramView, localAnimationSet, 1000L, 0L);
    }
}

Related Tutorials