Two ways to switch animations for Android activity

Source: Internet
Author: User

Method one overridependingtransition (0,0)

void android.app.Activity.overridePendingTransition (int enteranim, int exitanim) call immediately after one of the Flavors of startactivity (Intent) or finish to specify a explicit transition animation to perform next. Parameters:enteranim A Resource ID of the animation resource to use for the incoming activity. Use 0 for no Animation.exitanim A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation.
The overridependingtransition function is provided in the activity,used after startactivity (Intent) and finish. Overridependingtransition has two parameters, all of which are of type int, meaning that a resource is passed in here. One is to enter the animation, one is to exit the animation, if the value is set to 0, it means not to add animation.

Examples of animationdrable resources:

<?xml version= "1.0" encoding= "utf-8"?><!--slide-in--><set xmlns:android= "http://schemas.android.com/ Apk/res/android ">    <translate        android:duration="        android:fromxdelta= "100%p"        android: Toxdelta= "0"/>    <alpha        android:duration= ""        android:fromalpha= "0.0" android:toalpha=        " 1.0 "/></set>

or consider using Android with an animated resource directly from Android. r.anim.*Method Two Android:theme
    <style name= "Themeactivity" mce_bogus= "1" >        <item name= "Android:windowanimationstyle" > @style/ activityanimation</item>        <item name= "Android:windownotitle" >true</item>    </style >    <style name= "Activityanimation" mce_bogus= "1" parent= "@android: style/animation.activity" >        < Item Name= "Android:activityopenenteranimation" > @anim/anim_enter</item>        <item name= "Android: Activityopenexitanimation "> @anim/anim_exit</item>        <item name=" Android: Activitycloseenteranimation "> @anim/back_enter</item>        <item name=" Android: Activitycloseexitanimation "> @anim/back_exit</item>    </style>
parent= "@android: style/animation.activity" is not rare,
<item name= "Android:windownotitle" >true</item> optional.

Use of Android:theme

        <activity            android:name= "com.tpx.androiddemo.SecondActivity"            android:label= "@string/title_activity_ Second "            android:theme=" @style/themeactivity ">        </activity>


Two ways to switch animations for Android activity

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.