1 Activity's toggle animation refers to the animation that jumps from one activity to another activity.
It consists of two parts:
Part of the animation when the first activity exits;
Another part when the second activity enters the animation;
After the 2.0 version of Android, there is a function to help us implement this animation. This function is Overridependingtransition
This function has two parameters, one parameter is the animation when the first activity enters, and the other is the animation when the second activity exits.
Here's a special note about the Overridependingtransition function, which has two points that require an idea.
1. It must be called next to the StartActivity () or Finish () function.
2. It only works on android2.0 and above
2 But sometimes overridependingtransition this function will not work, summed up, is probably the following three reasons:
1, Android system version 2.0 below, this no way, think of other ways to solve the switch animation bar. 2, in the Activitygroup and other embedded activity, this is easier to solve, with the following methods can be: This.getparent (). Overridependingtransition can be solved. 3, in an activity of the inner class, or anonymous class, this time had to use handler to solve. 4, the display animation effect of the mobile phone is closed by man or other way. Now open to set-up display animation effect
An animation that implements two Activity transitions. Use in activity
There are two parameters: animations that go into animations and go out.
Attention
1. Must be called immediately after startactivity () or finish ().
2, and in more than 2.1 version valid
3, Phone settings-display-animation, to turn on the state
Achieve fade-out effect
StartActivity (New Intent (Mainactivity.this,secondactivity.class));
Overridependingtransition (Android. R.anim.fade_in,android. R.anim.fade_out);
Effects that slide from left to right
StartActivity (New Intent (Mainactivity.this,secondactivity.class));
Overridependingtransition (Android. R.anim.slide_in_left,android. R.anim.slide_out_right);
Implement Zoommin and Zoomout (custom animations)
StartActivity (New Intent (Overridependingtransitionactivity.this,secondactivity.class));
Overridependingtransition (R.anim.zoomin, r.anim.zoomout);
Anim/zoomin.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<set xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:interpolator= "@android: Anim/decelerate_interpolator" >
<scale
Android:duration= "@android: Integer/config_mediumanimtime"
Android:fromxscale= "0.1"
Android:fromyscale= "0.1"
android:pivotx= "50%p"
Android:pivoty= "50%p"
Android:toxscale= "1.0"
Android:toyscale= "1.0"/>
<alpha
Android:duration= "@android: Integer/config_mediumanimtime"
Android:fromalpha= "0"
Android:toalpha= "1.0"/>
</set>
Anim/zoomout.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<set xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:interpolator= "@android: Anim/decelerate_interpolator"
android:zadjustment= "Top" >
<scale
Android:duration= "@android: Integer/config_mediumanimtime"
Android:fromxscale= "1.0"
Android:fromyscale= "1.0"
android:pivotx= "50%p"
Android:pivoty= "50%p"
Android:toxscale= "0.1"
Android:toyscale= "0.1"/>
<alpha
Android:duration= "@android: Integer/config_mediumanimtime"
Android:fromalpha= "1.0"
Android:toalpha= "0"/>
</set>
Use of Android-----overridependingtransition