Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set android animation list programmatically

I am trying to achieve adding the animated gifs into my application.

1- I am able to download the animated gif from server. 2- I am able to decode the animated gif (using my custom decoder) and have a separate Bitmap corresponding to its frames.

Now I want to animate it using the frame by frame animation. As i read, to perform the frame by frame animation the first thing that is required is "animation-list".

I want to know how i can create the required "animation-list" programatically containing each Bitmap as a separate frame.

like image 560
confucius Avatar asked Jul 03 '11 15:07

confucius


1 Answers

You can use AnimationDrawable similiar to http://androidforums.com/application-development/11620-programmatic-frame-frame-animation-examle-animationdrawable.html but use your own files instead of taken from resources.

Note that you have to be careful about density of screen and bitmaps which are downloaded rather than taken from resources otherwise it might look differently on different screen sizes/resolutions. More about it here: http://developer.android.com/guide/practices/screens_support.html see particularly "Scaling Bitmap Objects created at runtime" chapter

like image 194
Jarek Potiuk Avatar answered Oct 26 '22 19:10

Jarek Potiuk