Android examples for User Interface:View Animation
get Main Start Animation
//package com.java2s; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.ScaleAnimation; import android.view.animation.TranslateAnimation; public class Main { public static final int DURATION = 700; public static final int ALPHA_DURATION = 600; public static Animation getMainStartAnimation() { AnimationSet animationSet = new AnimationSet(false); AlphaAnimation alphaAnimation = (AlphaAnimation) getFadeInAnimation(ALPHA_DURATION * 4); TranslateAnimation translateAnimation1 = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, -0.1f, Animation.RELATIVE_TO_PARENT, 0.1f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f); translateAnimation1.setDuration(DURATION / 5); translateAnimation1.setRepeatMode(Animation.REVERSE); translateAnimation1.setRepeatCount(DURATION / (DURATION / 5) - 1); ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setDuration(ALPHA_DURATION + DURATION); TranslateAnimation translateAnimation2 = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0.8f, Animation.RELATIVE_TO_PARENT, 0f); translateAnimation2.setDuration(DURATION + ALPHA_DURATION); TranslateAnimation translateAnimation3 = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, -0.1f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0f); translateAnimation3.setDuration(DURATION / 5); translateAnimation3.setStartOffset(DURATION); animationSet.addAnimation(alphaAnimation); animationSet.addAnimation(translateAnimation1); animationSet.addAnimation(scaleAnimation); animationSet.addAnimation(translateAnimation2); animationSet.addAnimation(translateAnimation3); animationSet.setFillAfter(false); return animationSet; }/*from w ww . ja va 2 s . c om*/ public static Animation getFadeInAnimation() { return getFadeInAnimation(DURATION * 2); } private static Animation getFadeInAnimation(int duration) { AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f); alphaAnimation.setDuration(duration); return alphaAnimation; } }