My Android advanced tour ------ & gt; Frame Animation instance of Android Animation

Source: Internet
Author: User


Filename. Xml
The filename will be used as the resource ID.
.
Filename
In XML: package:]drawable.filename
Required. This must be the root element. Contains one or more  elements.

Boolean. "true" if you want to perform the animation once; "false" to loop the animation.
 element.

Drawable resource. The drawable to use for this frame.
Integer. The duration to show this frame, in milliseconds.

= ==================================

<? 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/p1" android: duration = "500"/> <item android: drawable = "@ drawable/p2" android: duration = "500"/> <item android: drawable = "@ drawable/p3" android: duration = "500"/> <item android: drawable = "@ drawable/p4" android: duration= "500"/> <item android: drawable = "@ drawable/p5" android: durat Ion = "500"/> <item android: drawable = "@ drawable/p6" android: duration = "500"/> </animation-list> <! -- Android: oneshot indicates whether to run only once. If it is set to false, the <item> element of loop playback indicates an animation. android: drawable specifies the image resources corresponding to the animation, android: druation indicates the duration of the frame, an integer in milliseconds. -->

Step 4: layout file res/layout/main. xml of the application

<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: orientation = "vertical" android: layout_width = "fill_parent" android: layout_height = "fill_parent"> <! -- Frame Animated Image --> <ImageView android: id = "@ + id/ImgDance" android: layout_width = "fill_parent" android: layout_height = "fill_parent" android: layout_weight = "1"/> <! -- Android: layout_weight = "1" if this attribute is not set, the following two buttons are overwritten and not displayed --> <! -- Animation control Button --> <Button android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: text = "start dancing" android: onClick = "runFrame"/> <Button android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: text = "End dancing" android: onClick = "stopFrame"/> </LinearLayout>

Step 5: The main file of the application, FrameActivity. java

The effect is as follows:






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.