0

I am having hard time to perform frame by frame Animation in my App from last 3 days. I have around 90 images in drawable folder to perform Animation.

Firstly I have tried AnimationDrawbale but it gets out of memory error. Also I have applied android:LargeHeap="true" but still it is out memory error.

Secondly I tried it with this class https://github.com/tigerjj/FasterAnimationsContainer/blob/master/src/com/tigerlee/libs/FasterAnimationsContainer.java but here the problem comes is the Animation is very slow in it. I want it to be very smooth.

Please help. Stuck in it from very long time.

Android Geek
  • 598
  • 1
  • 5
  • 20

1 Answers1

0

Unfortunately frame-by-frame animations require a lot of memory and (depending on the frame sizes and count involved) can quickly cause OutOfMemoryExceptions as they are loaded with all frames at once. Retrieving each frame seperately causes the animation to slow down, as the system has to read each frame before displaying it. Thus, depending on your situation, there are the following options you can pursue:

  • Remove the animation: I myself have chosen this option a few times after carefully considering the necessity of the (loading, in my case) animation. The frame-by-frame animation had a huge performance penalty that just wasn't worth it.
  • Tweak your animation: In order to lower the memory usage of the animation you should consider either reducing the resolution of your frames or the total frame count involved (or both).
  • Use other animations: There are other animation options available including Animator since API level 11 and AnimatedVectorDrawable starting with API level 11 (using the support libraries). Depending on the kind of animation you have, you can migrate to one of those two.
TR4Android
  • 3,200
  • 16
  • 21