天天看点

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"这种设置方式是使用绝对位置定位的。