drawable Animations
Frame-by-frame animations is a frame-by-frame format that displays animation effects. Similar to the technique of film film shooting.
* Frame Animation:
* 1. Create the Drawable folder under the Res folder to create an XML file
* animation-list Label
* 2. Introduce this XML file in Layout controls
* 3. Get Animationdrawable Object
* 4. Call the Start method and the Stop method in Animationdrawable
The first step
Create Animation.xml under/res, drawable/,
Use <animation-list/> tags,
<?XML version= "1.0" encoding= "Utf-8"?><animation-listxmlns:android= "Http://schemas.android.com/apk/res/android" > <item android:drawable= "@drawable/wifi1"//Picture playedandroid:duration= "+">//Play Time </Item> <Itemandroid:drawable= "@drawable/wifi2"android:duration= "+"> </Item> <Itemandroid:drawable= "@drawable/wifi3"android:duration= "+"> </Item> <Itemandroid:drawable= "@drawable/wifi4"android:duration= "+"> </Item> <Itemandroid:drawable= "@drawable/wifi5"android:duration= "+"> </Item> <Itemandroid:drawable= "@drawable/wifi6"android:duration= "+"> </Item></animation-list>
The second step in the layout file development component introduces the XML
<ImageViewAndroid:id= "@+id/imageview1"Android:layout_width= "200DP"Android:layout_height= "200DP"Android:layout_alignparenttop= "true"Android:layout_centerhorizontal= "true"Android:layout_margintop= "90DP" android:src= "@drawable/animation" />
* 3. Get Animationdrawable Object
* 4. Call the Start method and the Stop method in Animationdrawable
Public classMainactivityextendsActivity {ImageView IV; Animation Animation; animationdrawable drawable; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); IV=(ImageView) Findviewbyid (R.ID.IMAGEVIEW1); Drawable= (animationdrawable) iv.getdrawable (); } Public voidClick (View v) {Switch(V.getid ()) { Caser.id.button1: drawable.start (); Break; Caser.id.button2: drawable.stop (); default: Break; } } }
Android Animation (2) Frame animation