Android Animation (2) Frame animation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.