views:

352

answers:

2

Hi! I want to display animated gifs in my aplication. As I found out the hard way Android doesn't support animated gifs natively.

However it can display animations using AnimationDrawable: http://developer.android.com/guide/topics/graphics/2d-graphics.html#frame-animation

The example uses animation saved as frames in application resources but what I need is to display animated gif directly.

My plan is to break animated gif to frames and add each frame as drawable to AnimationDrawable.

Does anyone know how to extract frames from animated gif and convert each of them into Drawable?

Thanks!

A: 

First of all the Android browser should support Animated GIFs. If it doesn't then it's a bug! Have a look at the issue trackers.

If you're displaying these animated GIFs outside of a browser it might be a different story. To do what you're asking would require external library that supports the decoding of Animated GIFs.

The first port of call would be to look at Java2D or JAI (Java Advanced Imaging) API, although I would be very surprised if Android Dalvik would support those libraries in your App.

Amorgos
A: 

I solved the problem by splitting gif animations into frames before saving it to phone, so I would not have to deal with in in Android.

Then I download every frame onto phone, create Drawable from it and then create AnimationDrawable - very similar to example from my question

Leonti