标签:
1、首先先创建四个动画文件
①:left_in.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="600" android:fromXDelta="-100.0%p" android:toXDelta="0.0" /> </set>
②:left_out.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="600" android:fromXDelta="0.0" android:toXDelta="-100.0%p" /> </set>
③:right_in.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="600" android:fromXDelta="100.0%p" android:toXDelta="0.0" /> </set>
④:right_out.xml
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="600" android:fromXDelta="0.0" android:toXDelta="100.0%p" /> </set>
2、在styles.xml里写一个风格
<style name="MyTheme" parent="AppTheme"> <item name="android:windowAnimationStyle">@style/ActivityAnimation</item> </style> <style name="ActivityAnimation"> <item name="android:activityOpenEnterAnimation">@anim/slide_right_in</item> <item name="android:activityOpenExitAnimation">@anim/slide_left_out</item> <item name="android:activityCloseEnterAnimation">@anim/slide_left_in</item> <item name="android:activityCloseExitAnimation">@anim/slide_right_out</item> </style>
3、然后将AndroidManifest.xml文件里面的<application>标签的主题换成我们写的就可以了
标签:
原文地址:http://www.cnblogs.com/819158327fan/p/5213473.html