Android-like WeChat activity switch left and right [global activity display animation configuration]

Source: Internet
Author: User

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.

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.