仿微信Activity跳转

res/anim下建立四个文件

文件1:slide_left_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set
  xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:duration="300" android:fromXDelta="-100.0%p" android:toXDelta="0.0" />
</set>

文件2:slide_left_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set
  xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:duration="300" android:fromXDelta="0.0" android:toXDelta="-100.0%p" />
</set>

文件3:slide_right_in.xml

<?xml version="1.0" encoding="utf-8"?>
<set
  xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:duration="300" android:fromXDelta="100.0%p" android:toXDelta="0.0" />
</set>

文件4:slide_right_out.xml

<?xml version="1.0" encoding="utf-8"?>
<set
  xmlns:android="http://schemas.android.com/apk/res/android">
    <translate android:duration="300" android:fromXDelta="0.0" android:toXDelta="100.0%p" />
</set>

 

自己调速度即可!!!!

重写res/values/styles.xml文件下的AppTheme,改为:

    <style name="AppTheme" parent="@android:style/Theme">     
        <!-- 设置activity切换动画 -->
        <item name="android:windowAnimationStyle">@style/activityAnimation</item>
    </style>
    
    <!-- animation 样式 -->
    <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>

修改AndroidManifest.xml文件application标签下的

android:theme="@style/AppTheme"

 

 

 

 

 

 

 

posted on 2013-05-10 15:56  精灵July  阅读(409)  评论(0编辑  收藏  举报

导航