The Android GIF Libraray (android-gif) adds support for GIF files in Android like existing structure of Android Bitmap. This is the simplest way to use GIFs in Android:
The following examples shows you how easy to use is this library:
final Gif myGif = GifFactory.decodeByteArray(gifBytes, 0, gifBytes.length);
final Gif myGif = GifFactory.decodeResource(context.getResources(), R.raw.my_gif);
final Drawable myDrawable = new GifDrawable(context.getResources(), myGif);
final Gif myGif = GifFactory.decodeStream(gifInputStream);
final Gif myScaledGif = Gif.createScaledGif(myGif, 200, 150, true);
final Gif myGif = GifFactory.decodeFile("test.gif");
final Drawable myDrawable = new BitmapDrawable(context.getResources(), myGif.getFrames()[0].getImage());
To use the android-gif-library in your application add this to your pom.xml in dependencies part:
<dependency>
<groupId>com.github.kleinerhacker</groupId>
<artifactId>android-gif-library</artifactId>
<version>1.0.0</version>
</dependency>
Alternative you can download the artifact and put it manuelly to your project.
- Loop Count faulty: Only one loop or endless loop supported