I need to show frame-animation on an ImageView. I am using AnimationDrawable to play the animation on some click event. Its working fine if I show single animation. But based on the button clicked I need to show three different animations.When I'm playing the second animation OutOfMemoryError is thrown. As suggested by some other post on the same issue I am recycling the bitmaps after the animation is over. But in app, on clicking the same button again I need to show the same Animation. But as I am trying to use recycled bitmaps its not working..is there any work around for this problem???
Asked
Active
Viewed 2,168 times
2
-
Not enough information at all to help out. Blind guess: Your images are too big. – meredrica Oct 12 '13 at 09:27
-
my images are all 450*420 and each animation has around 20 frames.. – lingareddyk Oct 12 '13 at 09:37
1 Answers
3
Following form comments: You load too much data.
Assuming ARGB images:
width x height x images x colordept = bytes used
450 * 420 * 20 * 4 = 30240000.
That's 14 MiB when you load the full animation. This is guaranteed to blow up your ram.

meredrica
- 2,563
- 1
- 21
- 24
-
I got your point..If I use single animation ,there is no prblem. So is there any way i can unload the first animation frames on animation completion(through bitmap.recycle()) and reload it later when i need it again.?? – lingareddyk Oct 12 '13 at 10:05
-
http://stackoverflow.com/questions/9082181/animation-drawable-causing-outofmemoryerror-on-second-run-in-android mentions a way to recycle them. – meredrica Oct 12 '13 at 11:35