Toggle animations between Android animation-activity

Source: Internet
Author: User

There are two ways in which animation can be toggled between pages in Android, one is code, and the other is defined to modify activity Theme.

First, the code implementation is relatively simple

You can modify the activity's toggle animation in real time by calling Overridependingtransition ().
Note, however, that the function must be called immediately after calling StartActivity () or finishe, and only once.


Two. Activity Theme

1. Enter the following code in Styles.xml:

<style name= "animationactivity" parent= "@android: style/animation.activity" >

        <item name= "Android:activityopenenteranimation" > @anim/fade_right_in</item>< when a new page is opened, Animations performed by new activity--        <item name= "android:activityopenexitanimation" > @anim/fade_left_out</item > <!--When a new page is opened, the old activity performs the animation--        <item name= "android:activitycloseenteranimation" > @anim/fade_ left_in</item><!--The current page is closed, the underlying activity performs the animation--        <item name= "Android: Activitycloseexitanimation "> @anim/fade_right_out</item>< the current activity is animated    when the current page is closed!-- </style>




2. Then in the Themes.xml

<style name= "themeactivity" >   <item name= "Android:windowanimationstyle" > @style/animationactivity </item>      <item name= "Android:windownotitle" >true</item>     </style>  




3. Specify theme for activity in Androidmanifest.xml.

<activity android:name= "com.example.activityanimation.SecendActivity" android:theme= "@style/themeactivity"/ >


Source:

http://download.csdn.net/detail/duanyu218/7451735

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.