您的位置:首页 > 其它

AnimationDrawabl的使用

2016-01-06 11:18 155 查看
自己写个帧动画zhuzhen

<?xmlversion="1.0"encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<itemandroid:drawable="@drawable/progress_1"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_2"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_3"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_4"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_5"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_6"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_7"android:duration="200"/>
<itemandroid:drawable="@drawable/progress_8"android:duration="200"/>
</animation-list>


android:oneshot=”false”的意思是循环播放

2.首先给图片设置

<ImageView
android:id="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@anim/zhuzhen"
android:layout_gravity="center"/>


AnimationDrawable anim= (AnimationDrawable) iv.getBackground();

anim.start();

注意点:anim.start();不能直接放入oncreate里面,,还没有真正的焦点获取

如果想启动界面自动执行start()的话 需要放入:onWindowFocusChanged里面
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: