天天看點

android之Animation使用方法二

animation的第二種使用方法:

1.在res檔案夾中建立一個名為anim的檔案夾。

2.在anim檔案夾中建立各個動畫的xml檔案

  在xml檔案中首先加入set标簽

<set xmlns:android="http://schemas.android.com/apk/res/android"

 android:interpolator="@android:anim/accelerate_interpolator">

 </set>

3.在該标簽當中加入alpha scal rotate或者translate标簽

4.在代碼中用AnimationUtils當中裝載xml檔案并生成Animation對象

舉例旋轉動畫标簽:

<rotate android:fromDegrees="0"

  android:toDegrees="360"

  android:pivotX="50%"

  android:pivotY="50%"

  android:duration="5000" />

android:pivotX共有三種設定方式:

android:pivotx="50"這種設定方式是使用絕對位置定位的。