Android or later
OverridePendingTransition (R. anim. translate_in, R. anim. translate_out) can be used to switch the animation.
But the trouble is that you must finish the previous one when switching the animation.
And you cannot control the animation at the return and end times.
Now there is a way to use theme to control
<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>
In this way, you can directly set theme for this activity in manifest. xml, which is much easier than using that system method.