在Andrio的中,可以使用多幅图片实现动画效果。
首先定义一个以 <animation-list>为根节点的xml文件,命名为 anim.xml 放在 res/drawable/目录下。
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/image1" android:duration="200" />
<item android:drawable="@drawable/image2" android:duration="200" />
<item android:drawable="@drawable/image3" android:duration="200" />
</animation-list>
ImageView image = (ImageView) findViewById(R.id.rocket_image);
image.setBackgroundResource(R.drawable.rocket_thrust);
AnimationDrawable animation = (AnimationDrawable) image.getBackground();
最后,在需要的时候启动动画即可。
animation.start();