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.