1overridePendingTransition
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 official gives us the animated effect
Achieve fade-out effects
Overridependingtransition (Android. R.anim.fade_in,android. R.anim.fade_out);
Effects that slide from left to right
Overridependingtransition (Android. R.anim.slide_in_left,android. R.anim.slide_out_right);
3overridependingtransition not working cause
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
4 Custom Animations
Step one: First declare two animation effects under Res/anim
Fade.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < xmlns:android= "http://schemas.android.com/apk/res/android" android: Interpolator= "@android: Anim/accelerate_interpolator" android:fromalpha= " 0.0 " android:toalpha=" 1.0 " android:duration=" @android: integer/ Config_longanimtime "/>
Hold.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < xmlns:android= "http://schemas.android.com/apk/res/android" android: Interpolator= "@android: Anim/accelerate_interpolator" android:fromxdelta= " 0 " android:toxdelta=" 0 " android:duration=" @android: integer/ Config_longanimtime "/>
Step Two: Add the Overridependingtransition method when the activity jumps
Refresh= (TextView) This.findviewbyid (R.id.refresh); Refresh.setonclicklistener (New Onclicklistener () { @Override public void OnClick (View v) { //TODO auto-generated method Stub Intent intent=new Intent (pathbuttonactivity.this,mainactivity.class); StartActivity (intent); The first argument is a start-up animation effect, the second argument is an exit animation effect overridependingtransition (R.anim.fade, r.anim.hold); } );
"Reprint" Two activity interface jump between animation effect