標籤:android style blog http io os ar 使用 for
Android提供了兩種類型的動畫:
一類是Tween動畫:提供了旋轉、移動、伸展和淡出等效果;
第二類是Frame-by-frame動畫:這一類Animations可以建立一個Drawable序列,這些Drawable可以按照指定的時間間歇一個一個的顯示;
這裡主要詳細看一下Tween動畫。
Tweened Animations一共有四類:
1、Alpha:淡入淡出效果
表示一個控制項的透明度的變化。通常使用其構造方法 AlphaAnimation(float fromAlpha, float toAlpha) 來產生一個對象。
留意兩個參數值的含義:
fromAlpha -- Starting alpha value for the animation, where 1.0 means fully opaque and 0.0 means fully transparent. // 動畫開始時的透明度,1.0表示完全不透明,0.0表示透明
toAlpha -- Ending alpha value for the animation. // 動畫結束時的透明度
2、Scale:縮放效果
表示一個控制項的展開收縮的效果變化。常用的建構函式 public ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
各個形參的意義:
fromX, toX -- // x軸的初始值和縮放後的值,相當與view從多大開始進行縮放變換,變換後有多大
fromY, toY -- // 與上類似,y軸的初始值和縮放後的值
pivotXType, pivotXValue -- // 縮放軸的類型,三個值Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_PARENT,表示縮放基點的x座標
pivotYType, pivotYValue -- // 與上類似,表示縮放基點的x座標;與上面兩個參數共同確定縮放的基點
3、Rotate:旋轉效果
表示一個控制項旋轉的效果。建構函式:public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
fromDegrees, toDegrees -- // 旋轉開始和結束的角度,以旋轉基點為參考的順時針方向角度
pivotXType, pivotXValue -- // 確定旋轉的基點x座標
pivotYType, pivotYValue -- // 確定旋轉基點的y座標,與上面共同確定了旋轉的基點
這邊配了一副網路上down過來的圖,方便分析。
4、Translate:移動效果
TranslateAnimation是描述控制項位置移動效果的動畫,An animation that controls the position of an object.
其建構函式為:public TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue, int fromYType, float fromYValue, int toYType, float toYValue)
fromXType, fromXValue --移動起始點的X座標,fromXType為枚舉Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, Animation.RELATIVE_TO_PARENT之一,
toXType, toXValue -- 移動結束位置的x座標
fromYType, fromYValue -- 移動起始點的Y座標,與fromX*一起確定移動開始的點
toYType, toYValue -- 移動結束點的Y座標,與toX*一起確定移動結束位置的點
android Tweened Animations