现在的位置: 首页 > 综合 > 正文

****Android动画效果translate、scale、alpha、rotate详解

2013年11月17日 ⁄ 综合 ⁄ 共 2028字 ⁄ 字号 评论关闭

http://blog.csdn.net/sun6255028/article/details/6735025

 

动画类型

Androidanimation由四种类型组成

XML

alpha 渐变透明度动画效果
scale 渐变尺寸伸缩动画效果
translate 画面转换位置移动动画效果
rotate 画面转移旋转动画效果



JavaCode

AlphaAnimation 渐变透明度动画效果
ScaleAnimation 渐变尺寸伸缩动画效果
TranslateAnimation 画面转换位置移动动画效果
RotateAnimation 画面转移旋转动画效果


Android动画模式

Animation主要有两种动画模式

一种是tweened animation(渐变动画)

XML JavaCode
alpha AlphaAnimation
scale ScaleAnimation



一种是frame by frame(画面转换动画)

XML中 JavaCode
translate TranslateAnimation
rotate RotateAnimation

Android动画解析

alpha xml 淡出效果


 

  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">   
  3. <alpha   
  4.     android:fromAlpha="1.0"    
  5.     android:toAlpha="0.0"    
  6.     android:duration="500"  />   
  7. </set>   
  8. <!--    
  9.     fromAlpha:开始时透明度   
  10.     toAlpha: 结束时透明度   
  11.     duration:动画持续时间 -->  

 

alpha xml 淡入效果

 

  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">   
  3. <alpha   
  4.     android:fromAlpha="0.0"    
  5.     android:toAlpha="1.0"    
  6.     android:duration="500"  />   
  7. </set>   
  8. <!--    
  9.     fromAlpha:开始时透明度   
  10.     toAlpha: 结束时透明度   
  11.     duration:动画持续时间 -->  

 

rotate.xml 旋转效果: 

[html] view
plain
copy

  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">  
  3. <rotate                                        
  4.     android:interpolator="@android:anim/accelerate_decelerate_interpolator"   
  5.     android:fromDegrees="300"   
  6.     android:toDegrees="-360"   
  7.     android:pivotX="10%"   
  8.     android:pivotY="100%"   
  9.     android:duration="10000" />   
  10. </set>   
  11. <!--    
  12.   fromDegrees   动画开始时的角度   
  13.   toDegrees     动画结束时物件的旋转角度,正代表顺时针     
  14.   pivotX    属性为动画相对于物件的X坐标的开始位置  
  15.   pivotY    属性为动画相对于物件的Y坐标的开始位置    -->   

 

scale.xml 缩放效果: 

 

  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <set xmlns:android="http://schemas.android.com/apk/res/android">   
  3. <scale     
  4.     android:interpolator= "@android:anim/decelerate_interpolator"         
  5.     android:fromXScale="0.0"     
  6.     android:toXScale="1.5"     
  7.     android:fromYScale="0.0"     

抱歉!评论已关闭.