An animated example of Android playing multiple images _android

Source: Internet
Author: User

This example describes an animation that Android plays with multiple images. Share to everyone for your reference, specific as follows:

You can play frames-by-frame images on Android, then produce a dynamic effect, prepare several consecutive pictures, then create a Anim folder under the source Res folder, and create a new XML

The XML code is as follows:

<?xml version= "1.0" encoding= "Utf-8"?> <animation-list xmlns:android=
"http://schemas.android.com/apk" /res/android "
android:oneshot=" true ">
<item android:drawable=" @drawable/c1 "android:duration=" 200 " />
<item android:drawable= "@drawable/c2" android:duration= "/> <item"
@ Drawable/c3 "android:duration="/>
<item android:drawable= "@drawable/c4" android:duration= ""/>
<item android:drawable=, "@drawable/c5" android:duration= "/> <item android:drawable=
" @ Drawable/c6 "android:duration="/>
</animation-list>

Where C1,c2,c3,c4,c5,c6 is the name of the added picture.

Place a ImageView control inside the form and write it in code:

_imageview1 = (ImageView) Findviewbyid (R.ID.IMAGEVIEW1),//placed ImageView control
//Set animation background
_ Imageview1.setbackgroundresource (r.anim.animation_list)//Where r.anim.animation_list is the resource name of the animated description file that was prepared in the previous step.
Get the Animated object
_animaition = (animationdrawable) _imageview1.getbackground ();

Finally, you can start the animation, the code is as follows:

Do you want to start only once?
_animaition.setoneshot (false);
if (_animaition.isrunning ())//is running?
{
_animaition.stop ()//Stop
}
_animaition.start ()/Start

For more information on Android-related content readers can view the site: "Android graphics and image processing skills summary", "Android Development introduction and Advanced Course", "Android debugging techniques and common problems solution summary", " Android Multimedia How-to Summary (audio, video, audio, etc), summary of Android Basic components usage, Android View tips Summary, Android layout layout tips and a summary of Android controls usage

I hope this article will help you with the Android program.

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.