可以通过两种方式,
一是通过定义 Activity 的主题
样式
在 styles.xml 中编辑如下代码:
<item
name
=
"android:activityOpenEnterAnimation"
>
@anim/slide_in_left
</
item
>
<item name
=
"android:activityOpenExitAnimation"
>
@anim/slide_out_left
</
item
>
<item name
=
"android:activityCloseEnterAnimation"
>
@anim/slide_in_right
</
item
>
<item name
=
"android:activityCloseExitAnimation"
>
@anim/slide_out_right
</
item
>
</style
>
添加 themes.xml 文件:
<style
name
=
"ThemeActivity"
>
<item name
=
"android:windowAnimationStyle"
>
@style/AnimationActivity
</
item
>
<item name
=
"android:windowNoTitle"
>
true
</
item
>
</style
>
在 AndroidManifest.xml 中给指定的 Activity 指定 theme。
二是覆写 overridePendingTransition 方法
overridePendingTransition(R.anim.fade, R.anim.hold);
来源:oschina
链接:https://my.oschina.net/glfei/blog/3166411