From Open Source China
Gifview is a view that does not directly display GIF images in Android. It can only be displayed through mediaplay. It is the same as imageview and supports GIF images.
Usage:
1-add gifview. jar to your project.
2-configure the basic attributes of GIF view in XML. gif view inherits from the View class, which is a UI control like button and imageview. For example:
<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 attributes in the Code:
// Get the gifview handle from XML
Gf1 = (gifview) findviewbyid(r.id.gif 1 );
// Set the GIF Image Source
Gf1.setgifimage(r.drawable.gif 1 );
// Add listener
Gf1.setonclicklistener (this );
// Set the display size, stretch, or compress
Gf1.setshowdimension (300,300 );
// Set the loading mode: First load and then display, while loading, only display the first frame and then display
Gf1.setgifimagetype (gifimagetype. cover );
The Jar package of GifView has four classes:
GifAction. java observer class to monitor whether the GIF is loaded successfully
Three members in GifFrame. java: current image, latency, And next Frame link.
GifDecoder. java decoding Thread class
GifView. java main class, including common methods, such as the GifView constructor, image source setting, latency, and painting.