Android Activity Toggle Animation effect

Source: Internet
Author: User

Setting the effect of left and right access for activity can be done by setting the theme in the Mainfest.xml file. You can also use Java code.

First, set the style

Let's look at the style of implementing the animation:

<style name= "Animationrtol" mce_bogus= "1" parent= "@<span style=" color: #ff0000; " >android:style/Animation.Activity</span> ">        <item name=" Android:activityopenenteranimation " > @anim/in_from_right</item>        <item name= "android:activityopenexitanimation" > @anim/out_to_left </item>        <item name= "android:activitycloseenteranimation" > @anim/in_from_left</item>        <item name= "Android:activitycloseexitanimation" > @anim/out_to_right</item>    </style>

In another style, reference the style of the animation style:

<style name= "Themertol" mce_bogus= "1" parent= "@android: Style/theme.notitlebar" >        <item <span style= " Color: #ff0000; " >name= "android:windowanimationstyle</span>" > @style/animationrtol</item>        <item name= " Android:windownotitle ">true</item>    </style>

Configuration of activity:

<activity            android:name= "com.diiji.police.CPActivity"            android:screenorientation= "Portrait            " Android<span style= "color: #ff0000;" >:theme</span>= "@style/themertol" >        </activity>
Flaw: If need activity1 jump to activity2,activity2 jump to Activity3, then I want to return to the activity3 when, jump directly to activity1. That is, in the activity2 jump to Activity3, Activity2 to finish off, then there will be a black screen phenomenon. Because Finishi's activity also has an animated effect of exiting.

To solve this problem, I use a singleton mode activity management class that specifies the finish activity2 when Activity3 calls Ondestory (). Of course, can also try, intent.flag_clear_top this way.



Second, Overridependingtransition (Android. R.anim.slide_in_left,android. R.anim.slide_out_right);

1 It must be called next to the StartActivity () or Finish () function
2. It only works on android2.0 and above

3.finish activity is not animated.

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.