本文主要讲解Drawable Animation,从xml实现,代码实现两个方面来讲解。
一 xml实现
通过xml来指定需要加载的帧,在res/drawable/
目录下,创建一个包含<animation-list>
的xml文件,命名为rocket_thrust.xml
,如下
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="true">
<item android:drawable="@drawable/rocket_thrust1" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust2" android:duration="200" />
<item android:drawable="@drawable/rocket_thrust3" android:duration="200" />
</animation-list>
以上的xml指定了3个帧,名为rocket_thrust1
,rocket_thrust2
,rocket_thrust3
,随后在代码中使用这个animation-list
:
AnimationDrawable rocke