Abhinava's Blog - Animated GIF ImageView Library For Android PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

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.
WHY A NEW LIBRARY?
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!!!).
THAY THE LIBRARY!
https://code.google.com/p/giflib/
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:
layout.xml
android:id="@+id/animatedGifImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_above="@+id/button1"
android:layout_below="@+id/textView1" />

Activity.java
animatedGifImageView =
((AnimatedGifImageView)findViewById(R.id.animatedGifImageView));
animatedGifImageView.setAnimatedGif(R.raw.animated_gif,
TYPE.FIT_CENTER);
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 :)

Unknown at 1:09 PM
Share

16 comments:
sourabh jain June 19, 2014 at 4:47 PM
It works fine. Thanks for your help. Can you please tell me How can I set height and width of
GIFImageView..
Reply

sourabh jain June 19, 2014 at 4:47 PM


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

newbie August 26, 2014 at 3:12 AM


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.
Reply

Abhinava Srivastava August 26, 2014 at 10:13 AM


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.
https://code.google.com/p/giflib/source/browse/src/com/abhi/gif/lib/example/MainActivity.jav
a
Reply

Anonymous September 3, 2014 at 5:13 PM


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.
Reply

Shoshi Joarder October 31, 2014 at 10:24 AM


This solution is not works in Android 4.0.4
Reply

Anonymous November 7, 2014 at 9:16 AM


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
java.io.IOException.. how i fix this? i want show gif image from local storage,thanks.
Reply

Mahesh Subudhi January 12, 2015 at 2:16 PM


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

Sahil Garg February 5, 2015 at 12:07 PM


https://giflib.googlecode.com/archive/a7d47d06a304874671d3fd62e8398510c7b1d428.zip
Reply

Anonymous February 5, 2015 at 10:19 PM


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

Naag March 28, 2015 at 8:36 AM


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.
Reply

Chandan Wadhwa August 7, 2015 at 1:17 PM


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.
Reply

Aman Ullah September 22, 2015 at 8:14 PM


i did work for me, thank u buddy
Reply

Tony Abraham October 7, 2015 at 11:15 AM


Awesome work. It works fine
Reply

shanaya November 10, 2015 at 11:02 AM


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

Unknown November 18, 2015 at 11:30 PM


Hi!

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


Reply

Enter your comment...

Comment as:

Publish

mohammad shoaib quraishi (Google)

Sign out

Notify me

Preview

Links to this post


Create a Link

Home

View web version


CONTRIBUTORS

Jann
Abhi
Unknown
Powered by Blogger.

You might also like