Read now

Android: Applying a .gif file using android-gif-drawable

I stuck at a situation last week where I want to show a continuously animating background to my android application. The first option that stuck my head was the Animated .SVG files (For all of you wondering what it is you can have a look here). But after working on it for sometime I quit as my animation is quite impossible with animated .SVG, as I have to apply the animation to each and every element and my requirement was quite large too.

So after so much of effort I switch to a much easier way, which I probably do every-time,  I moved to .gif. But as you know the android doesn’t have a view for applying .gif so I Google and found the library that can do it for me and the one suits my requirement. The library is android-gif-drawable. The library has its own custom views, in them if you pass a .gif they will show it in your android application. It is very simple just make your layout XML as

The drawable snowfall.gif is present in the res/drawable folder. The library detects itself weather the drawable provided is a .gif file or any other file and then handles it accordingly.

Warning: GIF files are heavier so don’t try to send it via network as it can take forever to download. Also as they are heavier to load to it can cause the OutOfMemoryError on some devices. In my case the file is present inside the application and I made sure my activity takes lesser memory so that there would be enough space for GIF file to load. So test on different devices before using the library.


. . .


Add Your Comment

Be the first to comment.

Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again