you need to get all this gif frame image as an individual, and then set it to an animation list in an XML file.
Here is your anim_progress.xml file code
<?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/i1" android:duration="500" /> <item android:drawable="@drawable/i2" android:duration="500" /> <item android:drawable="@drawable/i3" android:duration="500" /> <item android:drawable="@drawable/i4" android:duration="500" /> <item android:drawable="@drawable/i5" android:duration="500" /> <item android:drawable="@drawable/i6" android:duration="500" /> <item android:drawable="@drawable/i7" android:duration="500" /> <item android:drawable="@drawable/i8" android:duration="500" /> </animation-list>
set the duration of the change as a smooth effect to get an animated image like gif
Here is the code to use this file
ImageView iv = new ImageView(this); iv.setBackgroundResource(R.drawable.anim_progress); final AnimationDrawable mailAnimation = (AnimationDrawable) iv.getBackground(); iv.post(new Runnable() { public void run() { if ( mailAnimation != null ) mailAnimation.start(); } });
setContentView (IV);
You can get all the frames from the gif file from this site.
http://gif-explode.com/
eg
http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif
this link will just pass it and you will get all the images of the frames
Pratik
source share