Friday, April 11, 2014

Animated GIF ImageView Library for Android

Okay Good People!!!
Announcing today a brand new library which is intended to help you out with displaying Animated GIF's within your applications.

As an Android developer you would have noticed that Android has not provided support for Animated GIF's as a component.
Therefore in order to show an Animated GIF's we usually end up using WebView in application which has its own disadvantages (Memorish Isuuess!!!).


Screenshot of Sample Application

The Sample application demonstrate that the Library Can handle both regular Image (PNG/JPG) and Animated GIF on same View. Therefore giving developer the flexibility to use Image/GIF without making any changes to his/her code base.

Sample Implementation:

        android:layout_below="@+id/textView1" />
animatedGifImageView = ((AnimatedGifImageView)findViewById(;
That's It!

AnimagedGifImageView supports some basic parameters to give you better control of image resizing (If required) There fore you can pass :

FIT_CENTER: Stretch and fit image while maintaining aspect ratio
STREACH_TO_FIT: Stretch Image irrespective of aspect ratio
AS_IS: Place the image without any manipulations.

Hope you will use the library and make your life easier :)


sourabh jain said...

It works fine. Thanks for your help. Can you please tell me How can I set height and width of GIFImageView..

sourabh jain said...

Please tell me how can I set height and width..

newbie said...

can you please add the complete code of your sample app? what is AnimatedGifImageView? as in android studio I'm receiving an error with this.

Abhinava Srivastava said...

Hey Saurabh, simply set the size of GifImageView like you will do for any View. And set the image inside as fit XY.

@Newbie: You can use the sample provided with the library itself. Cheers.

Anonymous said...

Thank you for the Library. It works but, the size of the gif image is not stable. I used a timer to show different animated images once in 10 seconds, and eachtime the size differs (I used different flags and it wont help : STREACH_TO_FIT, AS_IS, FIT_CENTER). I tried to invalidate, but it didnt solve the problem. Any idea why this happens?
Also it looks like there is a memory leak. I use the library to show a list of files, and the memory usage is increasing as time goes and is not returned by GC.

Shoshi Joarder said...

This solution is not works in Android 4.0.4

Anonymous said...

first, thanks for tutorial, i follow this code and work fine..
i try to add something diferent, i load gif image from local storage,but i get this logcat how i fix this? i want show gif image from local storage,thanks.

Mahesh Subudhi said...

can u please provide link of library from where to download.

Sahil Garg said...

Anonymous said...

I use AnimatedGifImageView in listview. but error java.lang.NullPointeEexception

Naag said...

with your library i am able to show the GIF but the problem is the GIF is looping.
WHere as the same GIF if i open in browser it is not looping. I only created the GIF with no loop.

Anonymous said...

Its working fine. Could you please tell me how to set gif image path from Activity instead of giving hard coded from init method of GifView class.

Aman Ullah said...

i did work for me, thank u buddy

Tony Abraham said...

Awesome work. It works fine

shanaya said...

wow..its work
can you please tell me if i have 20 gif images...and i want images changes on button click thanks!

Unknown said...


I would like to download Your library but there's nothing on GitHub.

Unknown said...

The link has been updated.