Android Activity switches animation Effects
You can set the effect of left and right access for the Activity by setting the topic in the Mainfest. xml file. You can also use java code.
1. Set styles
First, let's look at the animation style:
<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>
Reference the style of the animation style in another 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>
Activity Configuration:
<activity android:name="com.diiji.police.CPActivity" android:screenOrientation="portrait" android<span style="color:#ff0000;">:theme</span>="@style/ThemeRToL" > </activity>
Defect: If you need to jump from activity1 to activity2 and from activity2 to activity3, I want to directly jump to activity1 when activity3 returns. That is, when activity2 jumps to activity3, activity2 needs to finish, and black screen will appear at this time. Because finishi's activity also has the exit animation effect.
To solve this problem, I use an activity management class in singleton mode and specify finish activity2 when activity3 calls onDestory. Of course, you can also try Intent. FLAG_CLEAR_TOP.
2. overridePendingTransition (android. R. anim. slide_in_left, android. R. anim. slide_out_right );
1. It must be called next to startActivity () or finish ().
2. It is applicable only to android2.0 and later versions.
3. There will be no animation for the finish activity.