第1步:准备几张循环播放的图片
第2步:在drawable文件夹新建xml文件 ac.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/pulltorefresh_anima_left"
android:duration="200"/>
<item
android:drawable="@drawable/pulltorefresh_anima_right"
android:duration="200"/>
</animation-list>
第3步:布局文件里新增ImageView控件
<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:scaleType="center"
android:layout_centerInParent="true"
android:layout_height="wrap_content" />
第4步:Java代码实现
ImageView iv = (ImageView) findViewById(R.id.iv);
iv.setBackgroundResource(R.drawable.ac);
AnimationDrawable animationDrawable = (AnimationDrawable)iv.getBackground();
animationDrawable.start();
效果图: