In Android, you can play frames by frame, then create a dynamic effect, prepare several consecutive pictures, and then in the source program Res folder to create the Anim folder, and then 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 = "$" />
- < Item android: drawable = "@drawable/c2" android:duration = "$" />
- < item android:drawable = "@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 the code:
_imageview1 = (ImageView) Findviewbyid (R.ID.IMAGEVIEW1);//ImageView controls placed
- //Set animation background
- _imageview1.setbackgroundresource (r.anim.animation_list); //Where r.anim.animation_list is the resource name for the animated description file that was prepared in the previous step
- //Get animated object
- _animaition = (animationdrawable) _imageview1.getbackground ();
- Finally, you can start the animation, the code is as follows:
- //Is it only started once?
- _animaition.setoneshot (false);
- if (_animaition.isrunning ()) //Are you running?
- {
- _animaition.stop (); //Stop
- }
- _animaition.start (); //Start
How Android plays multiple images to form an animation