animation on View - Android User Interface

Android examples for User Interface:View Animation

Description

animation on View

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 {
    private static void animation(View paramView, Animation paramAnimation,
            long paramLong1, long paramLong2) {
        paramAnimation.setDuration(paramLong1);
        paramAnimation.setStartOffset(paramLong2);
        paramView.setVisibility(0);/*from w  ww  . j a  v  a2 s .  c o  m*/
        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