This paper realizes the translation animation between several interfaces as follows
This article address: http://www.cnblogs.com/wuyudong/p/5954847.html, reprint please indicate the source.
Analysis:
Panning the animation while the navigation interface is moving
Previous page move into animation (-screen width, y)------> (0,y)
Previous page move out animation (0,y)--------------> (screen width, y)
Next page move into animation (screen width, y)--------------> (0,y)
Next page move out animation (0,y)--------------> (-screen width, y)
Create a new Anima folder under the Res folder and create a new file of four Translate.xml types under the folder
The relevant code is as follows:
Pre_in_anim.xml
<?XML version= "1.0" encoding= "Utf-8"?><!---100%p Negative One screen width size value -<Translatexmlns:android= "Http://schemas.android.com/apk/res/android"Android:fromxdelta= " -100%p"Android:toxdelta= "0"android:duration= "$"></Translate>
Pre_out_anim.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < Translate xmlns:android = "Http://schemas.android.com/apk/res/android" android:fromxdelta= "0" android:toxdelta= "100%p" Android:duration= "$"></translate>
Next_in_anim.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < Translate xmlns:android = "Http://schemas.android.com/apk/res/android" android:fromxdelta= "100%p" android:toxdelta= "0" Android:duration= "$"></translate>
Next_out_anim.xml
<? XML version= "1.0" encoding= "Utf-8" ?> < Translate xmlns:android = "Http://schemas.android.com/apk/res/android" android:fromxdelta= "0" android:toxdelta= " -100%p" android:duration = "$" > </ Translate >
Then add the following code to the button click event in the 4-interface code
In the Prepage button, add:
Overridependingtransition (R.anim.pre_in_anim, R.anim.pre_out_anim);
In the NextPage button, add:
Overridependingtransition (R.anim.next_in_anim, R.anim.next_out_anim);
Android Mobile Defender--translation animation implementation