首先可以先定义一个逐帧播放的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/on_001" android:duration="100"/> <item android:drawable="@drawable/on_002" android:duration="100"/> <item android:drawable="@drawable/on_003" android:duration="100"/> <item android:drawable="@drawable/on_004" android:duration="100"/> <item android:drawable="@drawable/on_005" android:duration="100"/> <item android:drawable="@drawable/on_006" android:duration="100"/> </animation-list>
然后在代码中定义出AnimationDrawable对象,并设置到view的background上,然后设置开始播放就可以了:
AnimationDrawable ad = (AnimationDrawable) getResources().getDrawable(
R.drawable.bootanimation);
mView.setBackgroundDrawable(ad);
ad.start();
本文转自:http://www.cnblogs.com/janken/archive/2012/07/20/2601226.html