Android-animation during activity switching, android-activity
1. create four animation files first
①: 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. Write a style in 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. Replace the topic of the <application> tag in the AndroidManifest. xml file with the one we wrote.