Animations的使用(一)

2021-06-03 18:16:39 字數 2055 閱讀 6561

animation的分類:

一,tweened animations。旋轉,移動,伸展,淡出等效果。

二,frame-by-frame animations。可建立乙個drawable序列,按照指定的時間間隔乙個個顯示。

tweened animations分類:

1,alpha:淡入淡出

2,scale:縮放效果

3,rotate:旋轉效果

4,translate:移動效果

使用tweened animations的步驟:

1,建立乙個animationset物件。顧名思義,就是可以把幾個animation動作放到乙個set裡面。

2,根據需要建立相應的animation物件。animation的四個子類:alpha,scale,rotate,translate。

3,根據軟體動畫的需求,為animation物件設定相應的資料。

4,將animation物件新增到animationset物件中去。

5,使用控制項物件開始執行animationset。

**部分(alpha為例):

//建立animationset物件

animationset animationset=new animationset(true);

//建立animation物件

alphaanimation alphaanimation=new alphaanimation(1, 0);

//設定持續時間

alphaanimation.setduration(1000);

//把alpha加入到animationset裡面

animationset.addanimation(alphaanimation);

//為控制項新增動畫效果

iv_icon.setanimation(animationset);

四套api:

public

alphaanimation

(float fromalpha, float toalpha)

//引數一:開始的透明度,引數二:最後的透明度,1表示不透明,0表示完全透明。

public

rotateanimation

(float fromdegrees, float todegrees, int pivotxtype, float pivotxvalue, int pivotytype, float pivotyvalue)

//引數一:開始的度數,引數二:最終的度數,

引數三:軸x的型別(包括 animation.absolute, animation.relative_to_self(相對自己), animation.relative_to_parent(相對父元素))

引數四:x的值,0f到1f。相對位置。

引數五:軸y的型別,引數六:軸y的相對位置。

public

scaleanimation

(float fromx, float tox, float fromy, float toy, int pivotxtype, float pivotxvalue, int pivotytype, float pivotyvalue)

public

scaleanimation

(float fromx, float tox, float fromy, float toy, int pivotxtype, float pivotxvalue, int pivotytype, float pivotyvalue)

tween animation的通用屬性:

setfillafter(boolean fillafter)

//true動畫執行後停留在結束的狀態

setstartoffset(long startoffset)

//設定動畫執行的等到時間

setrepeatcount(int repeatcount)

//設定重複次數

Android之Animations的使用

animations一般分為兩大類,一類是漸變的 tweened 如淡入淡出,旋轉,移動,縮放 另一類是frame by frame,就如電影一般由多張按照一定的時間間隔顯示。使用tweened animations的第一種使用步驟 1.建立乙個animationset物件,animationset...

MyORM的使用 一

之前把自己寫過的乙個簡單orm類庫介紹了下,考慮到 會有改動而blog中編輯 太麻煩,在codeplex上建了乙個專案 myorm,相關 和檔案維護起來方便不少。簡單說一下自己寫orm的目的,個人不喜歡把實體物件搞得太複雜,因為在系統中實體是作為資料載體存在的,如果還要讓它負責資料庫操作 實體關係,...

Vim的使用(一)

命令操作h 游標向左移動乙個字元 j游標向下移動一行 k游標向上移動一行 l游標向右移動乙個字元 命令操作 w將游標移動到下乙個單詞的首字元 b將游標移動到上乙個單詞的首字元 e將游標移動到下乙個單詞的最後乙個字元 ge將游標移動到上乙個單詞的最後乙個字元 w將游標移動到下乙個空格的首字元 b將游標...