1.在res建立目录anim放入动画效果xml文件
1.1 进入文件 push_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%p"
- android:toXDelta="0" />
- <alpha
- android:duration="300"
- android:fromAlpha="0.0"
- android:toAlpha="1.0" />
- </set>
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android" >
- <translate
- android:duration="300"
- android:fromXDelta="0"
- android:toXDelta="-100%p" />
- <alpha
- android:duration="300"
- android:fromAlpha="1.0"
- android:toAlpha="0.0" />
- </set>
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/decelerate_interpolator" >
- <scale
- android:duration="@android:integer/config_mediumAnimTime"
- android:fromXScale="2.0"
- android:fromYScale="2.0"
- android:pivotX="50%p"
- android:pivotY="50%p"
- android:toXScale="1.0"
- android:toYScale="1.0" />
- </set>
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/decelerate_interpolator"
- android:zAdjustment="top" >
- <scale
- android:duration="@android:integer/config_mediumAnimTime"
- android:fromXScale="1.0"
- android:fromYScale="1.0"
- android:pivotX="50%p"
- android:pivotY="50%p"
- android:toXScale=".5"
- android:toYScale=".5" />
- <alpha
- android:duration="@android:integer/config_mediumAnimTime"
- android:fromAlpha="1.0"
- android:toAlpha="0" />
- </set>
- <style name="ThemeActivity">
- <item name="android:windowAnimationStyle">@style/AnimationActivity</item>
- <item name="android:windowNoTitle">true</item>
- </style>
- <style name="AnimationActivity" parent="@android:style/Animation.Activity">
- <item name="android:activityOpenEnterAnimation">@anim/push_left_in</item>
- <item name="android:activityOpenExitAnimation">@anim/push_left_out</item>
- <item name="android:activityCloseEnterAnimation">@anim/zoom_enter</item>
- <item name="android:activityCloseExitAnimation">@anim/zoom_exit</item>
- </style>
3.在Application中调用主题
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/ThemeActivity"
>
4. 测试过程中确保手机的动画效果开启,否则达不到效果
5. 源码下载地址 http://download.csdn.net/detail/lzqjfly/5095767