Android
The following 4 animation effects are available:
1. Alphaanimation Transparency Animation effect
2. Scaleanimation Zoom Animation effect
3. Translateanimation Displacement Animation effect
4. Rotateanimation Rotation animation effect
Today, we use displacement animations to implement the effects of the switching interface:
Translateanimation includes:
Float Fromxdelta The difference from the current view x-coordinate of the starting point of the animation
Float Toxdelta The difference in the end of the animation from the current view x-coordinate
Float Fromydelta The difference between the starting point of the animation and the current view y-coordinate
Float Toydelta The difference between the starting point of the animation and the current view y-coordinate
Usage
Animation.setduration (long Durationmillis);//Set animation duration
Animation.setrepeatcount (int i);//Set the number of repetitions
Animation.setrepeatmode (animation.reverse);//Set Reverse direction execution
Android:duration: The time the animation was run: the document was originally
-
android:duration
-
int. The time in milliseconds of the animation. 300MS is the default.
-
That is, the default is 300 milliseconds
Android:repeatcount: Defines when the animation repeats
Demo: Requirements, in the Android Setup Wizard, you may need to go to the next page, return to the previous page,
And then we're going to make it.
Slide from left to right
Translate_in.xml
<?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "Android:fromxdelta=" 100% "android:fromydelta=" 0 "android:toxdelta=" 0 "Andro Id:toydelta= "0" ></translate>
Translate_out.xml
<?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "android:fromxdelta=" 0 "android:fromydelta=" 0 "android:toxdelta=" -100% "Android Oid:toydelta= "0" ></translate>
How to use
/* Requires execution of */overridependingtransition (r.anim.translate_in, r.anim.translate_out) behind the finish () or StartActivity method;
Swipe from right to left:
Translate_precede_in.xml
<?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "Android:fromxdelta=" -100% "android:fromydelta=" 0 "android:toxdelta=" 0 "Android Oid:toydelta= "0" ></translate>
Translate_precede_in.xml
<?xml version= "1.0" encoding= "Utf-8"? ><translate xmlns:android= "http://schemas.android.com/apk/res/ Android "android:duration=" "android:fromxdelta=" 0 "android:fromydelta=" 0 "android:toxdelta=" 100% "Andro Id:toydelta= "0" ></translate>
How to use
Overridependingtransition (r.anim.translate_precede_in, r.anim.translate_precede_out);
Animations in Android