1. First create four animation files
①:left_in.xml
<? xml version= "1.0" encoding= "Utf-8" ?> < set xmlns:android = "Http://schemas.android.com/apk/res/android" > < translate android:duration = "" 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 = "" 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 = "" 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 = "" Android:fromxdelta = "0.0" Android:toxdelta = "100.0%p" /> </ set >
2. Write a style in Styles.xml
<stylename= "MyTheme"Parent= "Apptheme"> <Itemname= "Android:windowanimationstyle">@style/activityanimation</Item> </style> <stylename= "Activityanimation"> <Itemname= "Android:activityopenenteranimation">@anim/slide_right_in</Item> <Itemname= "Android:activityopenexitanimation">@anim/slide_left_out</Item> <Itemname= "Android:activitycloseenteranimation">@anim/slide_left_in</Item> <Itemname= "Android:activitycloseexitanimation">@anim/slide_right_out</Item> </style>
3, then the Androidmanifest.xml file inside the <application> tag theme for us to write on it.
Android--activity the animation when switching