Example: The decompiled package knows how to cook...
Androidmanifest. xml pay attention to the Android: Theme attribute of the application node.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.activityanimationdemo" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" /> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".OneActivity" android:label="@string/title_activity_main" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".TwoActivity" > </activity> <activity android:name=".ThreeActivity" > </activity> </application></manifest>
Here, the main part is styles. xml.
<Resources xmlns: Android = "http://schemas.android.com/apk/res/android"> <style name = "apptheme" parent = "@ Android: style/theme"> <! -- Set no title --> <item name = "Android: windownotitle"> true </item> <! -- Set activity switching animation --> <item name = "Android: windowanimationstyle"> @ style/activityanimation </item> </style> <! -- Animation style --> <style name = "activityanimation" parent = "@ Android: style/animation"> <item name = "Android: activityopenenteranimation "> @ anim/slide_right_in </item> <item name =" Android: activityopenexitanimation "> @ anim/slide_left_out </item> <item name =" Android: activitycloseenteranimation "> @ anim/slide_left_in </item> <item name =" Android: activitycloseexitanimation "> @ anim/slide_right_out </item> </style> </resources>
Slide_left_in.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromXDelta="-100.0%p" android:toXDelta="0.0" /></set>
Slide_left_out.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromXDelta="0.0" android:toXDelta="-100.0%p" /></set>
Slide_right_in.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromXDelta="100.0%p" android:toXDelta="0.0" /></set>
Slide_right_out.xml
<?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromXDelta="0.0" android:toXDelta="100.0%p" /></set>
The activity code is very simple, that is, startactivity does not need any special
Package COM. example. activityanimationdemo; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. view. view;/***** @ filename oneactivity. java * @ author naibo-liao * @ createtime 11:55:04 */public class oneactivity extends activity {public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. layout_one); findviewbyid (R. id. BTN ). setonclicklistener (new view. onclicklistener () {@ overridepublic void onclick (view v) {startactivity (new intent (oneactivity. this, twoactivity. class) ;}}); // returns the event findviewbyid (R. id. btn_exit ). setonclicklistener (new view. onclicklistener () {@ overridepublic void onclick (view v) {finish ();}});}}
Previous Engineering Drawing
That's all.