Download: http://code.google.com/p/gifview/downloads/list
Introduction: Android now does not directly display GIF view, only through the mediaplay to display, and often do not display properly, for this gifview, the use of the same as ImageView
How to use:
1-Add Gifview.jar to your project.
2-Configure the basic properties of Gifview in XML, Gifview inherits from the view class, and button, ImageView, is a UI control. Such as:
<com.ant.liao.gifview android:id="@+id/gif2" android:layout_height= " wrap_content " android:layout_width="wrap_content" android:paddingtop= " 4px " android:paddingleft="14px" android:enabled="false " />
3-Configure common properties in your code:
// get Gifview handle from XML GF1 = (Gifview) Findviewbyid (R.ID.GIF1); // set gif picture source Gf1.setgifimage (R.DRAWABLE.GIF1); // add listener Gf1.setonclicklistener (this ); // Set the displayed size, stretch, or compress Gf1.setshowdimension (300 , ); // set Load mode: Display first, edge load edge display, show first frame only Gf1.setgifimagetype (Gifimagetype.cover);
There are four classes of Gifview jar packages:
Gifaction.java:
Observer class to monitor whether GIF was loaded successfully
Package Com.ant.liao; Public Interface gifaction { /* * *gif decode Viewer * @hide * @param parsestatus decoding is successful, the success will be true * @param frameindex The current decoding of the first few frames, when all decoded successfully, here is- 1 */ Public void Parseok (boolean parsestatus,int frameindex); }
There are four classes of Gifview jar packages:
Gifaction.java:
Observer class to monitor whether GIF was loaded successfully
Package Com.ant.liao; Public Interface gifaction { /* * *gif decode Viewer * @hide * @param parsestatus decoding is successful, the success will be true * @param frameindex The current decoding of the first few frames, when all decoded successfully, here is- 1* /publicvoid Parseok ( Boolean parsestatus,int frameindex); }
Gifframe.java
Inside three members: current picture, delay, link to the next frame.
Package Com.ant.liao; Import Android.graphics.Bitmap; Public classGifframe {/** * constructor * @param im picture * @param del delay*/ PublicGifframe (Bitmap im,intdel) {Image=im; Delay=del; } PublicGifframe (String name,intdel) {ImageName=name; Delay=del; } /** Picture*/ PublicBitmap image; /** Delay*/ Public intdelay; /** File name when picture is saved*/ PublicString ImageName =NULL; /** Next Frame*/ PublicGifframe NextFrame =NULL; }
Android Open Source project: gifview--android Display gif animations