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://github.com/abhinavasr/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 :)