You can first define an XML that plays frames by frame:
<?XML version= "1.0" encoding= "Utf-8"?><animation-listxmlns:android= "Http://schemas.android.com/apk/res/android"Android:oneshot= "false" > <Itemandroid:drawable= "@drawable/on_001"android:duration= "+"/> <Itemandroid:drawable= "@drawable/on_002"android:duration= "+"/> <Itemandroid:drawable= "@drawable/on_003"android:duration= "+"/> <Itemandroid:drawable= "@drawable/on_004"android:duration= "+"/> <Itemandroid:drawable= "@drawable/on_005"android:duration= "+"/> <Itemandroid:drawable= "@drawable/on_006"android:duration= "+"/></animation-list>
Then define the Animationdrawable object in the code and set it to the background of the view and set it to start playing:
Animationdrawable ad = (animationdrawable) getresources (). getdrawable ( r.drawable.bootanimation); Mview.setbackgrounddrawable (AD); Ad.start ();
This article transferred from: http://www.cnblogs.com/janken/archive/2012/07/20/2601226.html
Android-animationdrawable (b)