One, activity toggle animation
In the Android development, often encounter activity between the transition effect, the following describes, the activity left and right sliding switch effect. After the Android2.0 version, the activity was added
1 /** * @method 3 * @param --int Enteranim: Activity when entering the screen animation 4 * @param 5 6 public void Overridependingtransition (int Enteranim, int Exitanim);
Ps:overridependingtransition (...) Method must be in StartActivity (...). or after the finish () method is called.
In Android, there are some animated effects that can be used by the Android.r.anim class. In general, use your own definition of activity switching animation effect, the following first understand the activity's location definition, as shown in:
(This image is from other posts)
As shown in the x-axis on the bottom of the phone, the left side of the phone is the y-axis. When x = -100%p, the activity position is in the left position of the screen (for example, position 1); when x = 0%p, the activity position is in the screen (such as position 2); when x = 100%p, the activity position is on the right side of the screen (such as position 3). The activity position of the y-axis is the same.
The following code is a two activity left and right slide transition effect:
1. Left out right into slide effect:
1 startactivityforresult (Intent, one); 2 // left out right in slide effect 3 overridependingtransition (r.anim.slide_right_in, r.anim.slide_left_out);
Slide_right_in.xml:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Set3 xmlns:android= "Http://schemas.android.com/apk/res/android">4 <Translate5 android:duration= "$"6 Android:fromxdelta= "100.0%p"7 Android:toxdelta= "0.0" />8 </Set>
Slide_left_out.xml:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Set3 xmlns:android= "Http://schemas.android.com/apk/res/android">4 <Translate5 android:duration= "$"6 Android:fromxdelta= "0.0"7 Android:toxdelta= " -100.0%p" />8 </Set>
2. Left-in-right out slide effect:
1 finish (); 2 // exiting right out slide effect 3 overridependingtransition (r.anim.slide_left_in, r.anim.slide_right_out);
Slide_left_in.xml:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Set3 xmlns:android= "Http://schemas.android.com/apk/res/android">4 <Translate5 android:duration= "$"6 Android:fromxdelta= " -100.0%p"7 Android:toxdelta= "0.0" />8 </Set>
Slide_right_out.xml:
1 <?XML version= "1.0" encoding= "Utf-8"?>2 <Set3 xmlns:android= "Http://schemas.android.com/apk/res/android">4 <Translate5 android:duration= "$"6 Android:fromxdelta= "0.0"7 Android:toxdelta= "100.0%p" />8 </Set>
Second, the animation XML tag
1. Android animation consists of four types of animations, respectively:
- Alpha: Gradient transparency animation effect;
- Scale: The gradient size scales the animation effect;
- Translate: Motion animation effect of the picture conversion position;
- Rotate: Picture transfer rotation animation effect;
2. Label Properties:
- Alpha
- Android:fromalpha: Transparency at the beginning;
- Android:toalpha: Transparency at the end;
- Androdi:duration: Duration of animation;
- Scale
- Translate
- Android:duration: Duration of animation;
- Android:fromxdelta: The element starts from a position;
- Android:toxdelta: The element stops at a certain position;
- Rotate
- Fromdegrees: The angle at which the animation starts;
- Todegrees: Angle at the end of the animation;
- Pivotx: The start position of the animation relative to the x-axis coordinates of the element;
- Pivoty: The start position of the animation relative to the y-axis coordinates of the element;
Android Animation Advanced Animation switch