Search code examples
androidperformanceandroid-animationandroid-memory

Best Way to Animate images frame by frame in Android


I have 3 sets of 50 images and I have to create the animations for each set of images in Android application. I am able to create a simple application which animate first set of 50 images using the below method,

Added Animation-list xml in drawable folder and called it using frameAnimation.start().

This method didn't work until I kept the following "android:largeHeap="true" in manifest file.

I am not sure whether this is the good way to animate the images (if we have more number of images and each image of more size like 60 KB. Image is JPG format) or not

I browsed and I found that, if we are able to clear the memory and if we are able to maintain less number of images in memory, then our application will work very fine. So I want to know how to clear the memory?

Please let me know do I need to follow different method to animate the images other than I explained above, so that I can clear the memory.

Thanks for your help.


Solution

  • After looking into several posts and doing much research, I finally ended up modifying the images in Imageview programmatically to simulate frame animation. That way I am just maintaining three images in cache at any point of time (previous, current and next one). I hope that this will be useful to others.