Activity进入与退出的动画

1.在res建立目录anim放入动画效果xml文件

   1.1   进入文件  push_left_in.xml 

[java]  view plain copy
  1. "1.0" encoding="utf-8"?>  
  2. "http://schemas.android.com/apk/res/android" >  
  3.   
  4.     
  5.         android:duration="300"  
  6.         android:fromXDelta="100%p"  
  7.         android:toXDelta="0" />  
  8.   
  9.     
  10.         android:duration="300"  
  11.         android:fromAlpha="0.0"  
  12.         android:toAlpha="1.0" />  
  13.   
  14.   
  1.2  退出文件  push_left_out.xml

[java]  view plain copy
  1. "1.0" encoding="utf-8"?>  
  2. "http://schemas.android.com/apk/res/android" >  
  3.   
  4.     
  5.         android:duration="300"  
  6.         android:fromXDelta="0"  
  7.         android:toXDelta="-100%p" />  
  8.   
  9.     
  10.         android:duration="300"  
  11.         android:fromAlpha="1.0"  
  12.         android:toAlpha="0.0" />  
  13.   
  14.   
  1.3  activity退出的效果  zoom_enter.xml  

[java]  view plain copy
  1. "1.0" encoding="utf-8"?>  
  2. "http://schemas.android.com/apk/res/android"  
  3.     android:interpolator="@android:anim/decelerate_interpolator" >  
  4.   
  5.     
  6.         android:duration="@android:integer/config_mediumAnimTime"  
  7.         android:fromXScale="2.0"  
  8.         android:fromYScale="2.0"  
  9.         android:pivotX="50%p"  
  10.         android:pivotY="50%p"  
  11.         android:toXScale="1.0"  
  12.         android:toYScale="1.0" />  
  13.   
  14.   
   1.4  zoom_exit.xml

[java]  view plain copy
  1. "1.0" encoding="utf-8"?>  
  2. "http://schemas.android.com/apk/res/android"  
  3.     android:interpolator="@android:anim/decelerate_interpolator"  
  4.     android:zAdjustment="top" >  
  5.   
  6.     
  7.         android:duration="@android:integer/config_mediumAnimTime"  
  8.         android:fromXScale="1.0"  
  9.         android:fromYScale="1.0"  
  10.         android:pivotX="50%p"  
  11.         android:pivotY="50%p"  
  12.         android:toXScale=".5"  
  13.         android:toYScale=".5" />  
  14.   
  15.     
  16.         android:duration="@android:integer/config_mediumAnimTime"  
  17.         android:fromAlpha="1.0"  
  18.         android:toAlpha="0" />  
  19.   
  20.   
2. 建立style文件

[java]  view plain copy
  1. "ThemeActivity">  
  2.        "android:windowAnimationStyle">@style/AnimationActivity  
  3.        "android:windowNoTitle">true  
  4.      
  5.   
  6.    "AnimationActivity" parent="@android:style/Animation.Activity">  
  7.        "android:activityOpenEnterAnimation">@anim/push_left_in  
  8.        "android:activityOpenExitAnimation">@anim/push_left_out  
  9.        "android:activityCloseEnterAnimation">@anim/zoom_enter  
  10.        "android:activityCloseExitAnimation">@anim/zoom_exit  
  11.      

3.在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


你可能感兴趣的:(动画)