koral-- /android-gif-drawable

Views and Drawable for displaying animated GIFs on Android

★ 9,642⑂ 1,787👁 308⑃ 175● 700▤ 64
JavaNOASSERTIONCreated 2013-01-30
Download: v1.2.32v1.2.32 ↓1.2.322026-06-18
-1
Daily
9,642
stars
1,787
forks
308
watchers
175
prs
700
issues
64
releases

README

!horizontal.png
====================









Views and Drawable for animated GIFs in Android.

 Overview
Bundled GIFLib via JNI is used to render frames. This way should be more efficient than WebView or Movie classes.

 Javadoc

 Setup

 Gradle (Android Studio)
Insert the following dependency to build.gradle file of your project.
groovy
dependencies {
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.32'
}

Note that Maven central repository should be defined eg. in top-level build.gradle like this:
groovy 
buildscript {
    repositories {
        mavenCentral()
    }
}
allprojects {
    repositories {
        mavenCentral()
    }
}

 Gradle, snapshot repository
Current development builds (build from dev branch) are published to OSS snapshot repository. To use them, specify repository URL in repositories block:
groovy
repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
dependencies {
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.+'
}

 Maven dependency

xml

    pl.droidsonroids.gif
    android-gif-drawable
    insert latest version here
    aar


 Eclipse
See Sample eclipse project with setup instructions.

 Download

Latest release downloads

Releases include android-gif-drawable-symbols-.tar.gz with unstripped native libraries,
for symbolicating native crashes, e.g. with ndk-stack
or by adding them to the native debug symbols uploaded to Google Play or Crashlytics.
They match the libraries from Maven Central by build ID.

 Requirements
+ Android 5.0+ (API level 21+)
+ for GifTextureView hardware-accelerated rendering
+ for GifTexImage2D OpenGL ES 2.0+

 Building from source
+ Android NDK needed to compile native sources

 Usage

 Sample project
See sample directory. Sample project is under construction. Not all features are covered yet.

 From XML
The simplest way is to use GifImageView (or GifImageButton) like a normal ImageView:
xml



If drawables declared by android:src and/or android:background are GIF files then they 
will be automatically recognized as GifDrawables and animated. If given drawable is not a GIF then
mentioned Views work like plain ImageView and ImageButton.

GifTextView allows you to use GIFs as compound drawables and background.
xml



 From Java code
GifImageView, GifImageButton and GifTextView have also hooks for setters implemented. So animated GIFs can be set by calling setImageResource(int resId) and setBackgroundResource(int resId)

GifDrawable can be constructed directly from various sources:

java
//asset file
GifDrawable gifFromAssets = new GifDrawable( getAssets(), "anim.gif" );
		
//resource (drawable or raw)
GifDrawable gifFromResource = new GifDrawable( getResources(), R.drawable.anim );
		
//Uri
ContentResolver contentResolver = ... //can be null for file:// Uris
GifDrawable gifFromUri = new GifDrawable( contentResolver, gifUri );

//byte array
byte[] rawGifBytes = ...
GifDrawable gifFromBytes = new GifDrawable

Top issues

Latest release

v1.2.32 v1.2.32 2026-06-18
What's Changed
 Fix JNI memory-safety bugs by @koral-- in https://github.com/koral--/android-gif-drawable/pull/873
   Fix use-after-free reading file size after ReleaseStringUTFChars in openFile (870)
   Add missing intptr_t cast in openNativeFileDescriptor return (871)
   Fix dangling pointer and leaks on eventfd failure in startDecoderThread (872)

Thanks @Fuyugithub for reporting.

Full Changelog: https://github.com/koral--/android-gif-drawable/compare/v1.2.31...v1.2.32

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON