AnimationDrawable

来源:互联网 发布:linux安装两个tomcat 编辑:程序博客网 时间:2024/04/29 20:07
?xml version="1.0" encoding="utf-8"?> 2 <animation-list xmlns:android="http://schemas.android.com/apk/res/android" 3     android:oneshot="false" > 4  5     <item 6         android:drawable="@drawable/on_001" 7         android:duration="100"/> 8  9     <item10         android:drawable="@drawable/on_002"11         android:duration="100"/>12 13     <item14         android:drawable="@drawable/on_003"15         android:duration="100"/>16 17     <item18         android:drawable="@drawable/on_004"19         android:duration="100"/>20 21     <item22         android:drawable="@drawable/on_005"23         android:duration="100"/>24 25     <item26         android:drawable="@drawable/on_006"27         android:duration="100"/>28 </animation-list>
复制代码

然后在代码中定义出AnimationDrawable对象,并设置到view的background上,然后设置开始播放就可以了:

1         AnimationDrawable ad = (AnimationDrawable) getResources().getDrawable(2                 R.drawable.bootanimation);3         mView.setBackgroundDrawable(ad);4         ad.start();

 

0 0