android Tweened Animations

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.