1.在drawable下创建donghua.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/sound_2" android:duration="100"/>
<item android:drawable="@drawable/sound_1" android:duration="100"/>
</animation-list>
<!--android:duration表示间隔时间 ,android:oneshot="false"设置为循环播放-->
2.在布局中调用
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/donghua"
android:id="@+id/donghua"/>
<!--设置background就好了 -->
3.java中创建一个动画
AnimationDrawable animationDrawable;
animationDrawable = (AnimationDrawable)imageView.getBackground();
animationDrawable.start();