Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


GifAnimationDrawable is a simple library (consisting of 2 classes) that makes it easy to display animated GIFs on the Android platform by converting the animated GIF file into an AnimationDrawable. This allows animated gifs to be used anywhere a Drawable is accepted, including backgrounds, standard ImageViews and anywhere else. For more detail, see

Animated GIFs are a simple way to make animations and are supported on Android using the Movie class: unfortunately the Movie class isn't quite as easy to use in many places as one might like. GifAnimationDrawable makes it trivial to use an animated gif as a standard Android Drawable, for backgrounds on buttons or views or as the main image in an ImageView. Solutions (such as this) require build-time processing, which isn't usable with downloaded images.

Enter this provides the key bit, the GifDecoder class that pulls out the individual frames. All that was missing was the final step, wrapping this in an AnimationDrawable instance.

And...we're done. See how to use it below.


Simply pass the image File or InputStream into the appropriate constructor:

AnimationDrawable drawable = new GifAnimationDrawable(File source);


AnimationDrawable drawable = new GifAnimationDrawable(InputStream source);

By default a Thread will be created to process the GIF frames (making the default operation safe to use on the main Android app thread): you can call the isDecoded method to be informed when the processing is complete. If you're loading this in an existing AsyncTask or other background thread, you can pass in a parameter to tell it to process the frames without spawning a new thread:

AnimationDrawable drawable = new GifAnimationDrawable(File source, true);


AnimationDrawable drawable = new GifAnimationDrawable(InputStream source, true);


The library build uses ant: you will need to have the ANDROID_SDK environment variable setup (or edit the build.xml file to point to the right place).

Open a shell in the library directory and run ant. The JAR file produced (gifanimationdrawable.jar) will contain the required files: add it to your Android app's libs folder, and then import the com.hipmob.gifanimationdrawable.GifAnimationDrawable class.



Developed by Femi Omojola ( for Orthogonal Labs, Inc. (


Use an animated GIF as an Android Drawable



No releases published


No packages published


You can’t perform that action at this time.