1.在layout增加:
<ProgressBar
android:id="@id/gf_loading"
style="@style/animStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</ProgressBar>
2.style定义
<style name="animStyle" parent="@android:style/Widget.ProgressBar.Large">
<item name="android:indeterminateDrawable">@anim/loading_gif</item>
</style>
3.在anim增加自己定义的动画
<?xml version="1.0" encoding="utf-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="50" android:drawable="@drawable/load_gif_0" />
<item android:duration="50" android:drawable="@drawable/load_gif_1" />
<item android:duration="50" android:drawable="@drawable/load_gif_2" />
</animation-list>
如果只是想让动画播放一次,将oneshot=“true”
这样创建的动画播放时,不会因为所依附的view没有创建完成导致死机