GifView: Android animated GIF image display control

Since there is no view for directly playing animated GIF pictures in Android, we can use the GifView control to realize the GIF picture display function.

The Jar package of GifView consists of four classes:

  • GifAction.java is mainly used to monitor whether the GIF image is loaded successfully
  • There are three members in GifFrame.java: the current picture, the delay, and the link to the next Frame.
  • GifDecoder.java decoding thread class
  • GifView.java is the core class, including the GifView constructor, and you can also set the image source, delay, drawing, etc.

How to use GifView

1. Download the GifView.jar package, click here to download. Then add the jar package to the project.

2. The xml configuration is as follows:

<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. The java code is as follows:

gf1 = (GifView) findViewById(R.id.gif1);
// set the Gif image source
gf1.setGifImage(R.drawable.gif1);
// add a listener
gf1.setOnClickListener(this);
// set the display size, Stretch or compress
gf1.setShowDimension(300, 300);
// set the loading method: first load and then display, while loading, display only the first frame and then display
gf1.setGifImageType(GifImageType.COVER);
// from xml Get the handle of
GifView gf1 = (GifView) findViewById(R.id.gif1);
// set Gif image source
gf1.setGifImage(R.drawable.gif1);
// add listener
gf1.setOnClickListener(this);
// set Display size, stretch or compress
gf1.setShowDimension(300, 300);
// Set the loading method: first load and then display, while loading, display only the first frame and then display gf1.setGifImageType(GifImageType.COVER);

GifView has great advantages in processing Gif images, and GifView can basically satisfy the basic processing method of GIF images.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326681092&siteId=291194637