About this project

android-gif-drawable is an open-source Android library that provides Views and Drawable classes for displaying animated GIFs. It bundles GIFLib via JNI to render frames, which is more efficient than using WebView or Movie classes. The library offers several ready-to-use View classes: GifImageView, GifImageButton, and GifTextView, which can be used directly in XML layouts or set programmatically. When a drawable assigned to these views is a GIF file, it is automatically recognized as a GifDrawable and animated. If the drawable is not a GIF, the views behave like standard ImageView or ImageButton. GifDrawable can be constructed from multiple sources including asset files, resources, URIs, byte arrays, FileDescriptors, file paths, Files, AssetFileDescriptors, InputStreams, and ByteBuffers. The library takes ownership of input streams and closes them automatically. Animation control is provided through methods such as stop(), start(), isRunning(), reset(), setSpeed(float), seekTo(int), getDuration(), and getCurrentPosition(). GifDrawable implements both Animatable and MediaPlayerControl interfaces, allowing integration with standard MediaController for playback controls and progress display. The library also exposes GIF metadata including loop count, number of frames, comment text, frame byte count, allocation byte count, and input source byte count. A MultiCallback mechanism allows a single GifDrawable instance to animate across multiple Views simultaneously. Requirements include Android 4.2+ (API level 17+), with hardware-accelerated rendering for GifTextureView and OpenGL ES 2.0+ for GifTexImage2D. Building from source requires the Android NDK. The library is available on Maven Central and supports Gradle, Maven, and Eclipse setups. It is licensed under the MIT License.