android2.0 above
You can use Overridependingtransition (r.anim.translate_in, r.anim.translate_out); This method toggles the animation
But the trouble is to toggle the animation time must finish the front one
And you can't control the animation at the back and end.
Now there's a way to control with theme
<style name= "MyTheme" >
<item name= "Android:windowanimationstyle" > @style/activityanimation</item>
</style>
<style name= "Animationactivity" >
<item name= "Android.activityopenenteranimation" > @anim/activity_open_enter</item>
<item name= "Android.activityopenexitanimation" > @anim/activity_open_exit</item>
<item name= "Android.activitycloseenteranimation" > @anim/activity_close_enter</item>
<item name= "Android.activitycloseexitanimation" > @anim/activity_close_exit</item>
</style>
This allows you to set theme on this activity directly in Manifest.xml, which is more convenient than using the system method.