Android Mobile Guardian Implementation translation animation example _android

Source: Internet
Author: User

This paper realizes the translation animation between the following several interfaces

Analysis:

Translation animation during the Navigation interface movement

Previous page Move animation (-screen width, y)------> (0,y)

Prev-Move animation (0,y)--------------> (screen width, y)

Next page Move animation (screen width, y)--------------> (0,y)

Next move out animation (0,y)--------------> (-screen width, y)

Create a new Anima folder under the Res folder, and create a new four translate.xml type of file under the folder

The relevant code is as follows:

Pre_in_anim.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<!---100%p minus one screen width size value-->
xmlns: 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

Add in the Prepage button:

Overridependingtransition (R.anim.pre_in_anim, R.anim.pre_out_anim);

Add in the NextPage button:

Overridependingtransition (R.anim.next_in_anim, R.anim.next_out_anim);

The above is a small series to introduce the Android mobile phone guardian to achieve translation animation, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.