private ImageView iv;
iv = (ImageView) findViewById(R.id.iv);
iv.setBackgroundResource(R.drawable.anim);
AnimationDrawable anim = (AnimationDrawable) iv.getBackground();
anim.start();
anim
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:drawable="@drawable/pic_1"
android:duration="100"/>
<item
android:drawable="@drawable/pic_2"
android:duration="100"/>
<item
android:drawable="@drawable/pic_3"
android:duration="100"/>
<item
android:drawable="@drawable/pic_4"
android:duration="100"/>
<item
android:drawable="@drawable/pic_5"
android:duration="100"/>
<item
android:drawable="@drawable/pic_6"
android:duration="100"/>
<item
android:drawable="@drawable/pic_7"
android:duration="500"/>
<item
android:drawable="@drawable/pic_8"
android:duration="100"/>
<item
android:drawable="@drawable/pic_9"
android:duration="100"/>
</animation-list>
是否循环播放
android:oneshot="true" 只播放一次
false 循环播放