1. Create a new displacement animation xml file
activate animation in Activity
To load an animation resource file using the Animationutils class
Left_to_right.xml
<? xml version= "1.0" encoding= "Utf-8" ?> < translate xmlns:android = "Http://schemas.android.com/apk/res/android" Android:fromxdelta = "100%" Android:toxdelta = "0" Android:duration = "" > </ translate >
View child=New Indexview (this). Getmemberview (); Child.startanimation ( Animationutils.loadanimation (This, r.anim.left_to_right));
2. Fade animation
Current fade-out interface and execution time
Fade out process, fading screen is in wait state
The second interface fades in and his execution time
After the first interface finishes executing, delete the
Packagecom.tsh.lottery.utils;ImportAndroid.support.v4.view.ViewPager;ImportAndroid.view.View;ImportAndroid.view.ViewGroup;Importandroid.view.ViewParent;Importandroid.view.animation.AlphaAnimation;Importandroid.view.animation.Animation;ImportAndroid.view.animation.Animation.AnimationListener; Public classFadeutil {/*** Fade Out interface *@paramView interface *@paramDuration Execution Time*/ Public Static voidFadeOut (FinalView View,Longduration) {alphaanimation alphaanimation=NewAlphaanimation (1, 0); Alphaanimation.setduration (duration); View.startanimation (alphaanimation); //Listen for animation end, delete view elementAlphaanimation.setanimationlistener (NewAnimationlistener () {@Override Public voidOnanimationstart (Animation Animation) {} @Override Public voidonanimationrepeat (Animation Animation) {} @Override Public voidonanimationend (Animation Animation) {viewgroup VG=(ViewGroup) view.getparent (); Vg.removeview (view); } }); } /*** fade-in interface *@paramView interface *@paramDelay Time *@paramDuration Execution Time*/ Public Static voidFadeIn (View view,LongDelayLongduration) {alphaanimation alphaanimation=NewAlphaanimation (0, 1); //set start time delayAlphaanimation.setstartoffset (delay); Alphaanimation.setduration (duration); View.startanimation (alphaanimation); }}
Fadeutil.fadeout (Child, 2000);
Fadeutil.fadein (Child, 2000,2000);
Simple animation of the [Android] interface switch