在drawable中写一个animation的xml,当作imageview的background:
<?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/loading_1"
android:duration="100"/>
<item
android:drawable="@drawable/loading_2"
android:duration="100"/>
<item
android:drawable="@drawable/loading_3"
android:duration="100"/>
<item
android:drawable="@drawable/loading_4"
android:duration="100"/>
<item
android:drawable="@drawable/loading_5"
android:duration="100"/>
<item
android:drawable="@drawable/loading_6"
android:duration="100"/>
<item
android:drawable="@drawable/loading_7"
android:duration="100"/>
<item
android:drawable="@drawable/loading_8"
android:duration="100"/>
<item
android:drawable="@drawable/loading_9"
android:duration="100"/>
<item
android:drawable="@drawable/loading_10"
android:duration="100"/>
<item
android:drawable="@drawable/loading_11"
android:duration="100"/>
<item
android:drawable="@drawable/loading_12"
android:duration="100"/>
</animation-list>
开始:
Animation anim = AnimationUtils.loadAnimation(getContext(), R.anim.loding);
mLoading.setVisibility(View.VISIBLE);
mLoading.startAnimation(anim);
结束:
VoiceToLayout.this.mLoading.clearAnimation();