Android Activity switches animation Effects

Source: Internet
Author: User

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.

Related Article

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.