0

I have a recyclerView with match parent items. In recyclerView item, I have 48 relative layouts and a background and it scrolls without any problems. Since I added lottie animationView in items, recyclerView scrolls but with lag. I tried to change the cache size, pause animation when it detached from window, compress background image, using another thread, converting images to bitmap but it did not help.

Should I try to draw views or something like it, or is there something else that I can do?

TylerH
  • 20,799
  • 66
  • 75
  • 101

2 Answers2

0

My solution is to use a different method to play the animation.

My first option was gif, but gif has transparency and if you have an animation that it has transparent parts, the animation has a white border that is very awful to use.

Another way to do this is to use apng; apng is an animated version of png and it resolves the problem of transparency, but in the recyclerView it has problems, like when you scroll the recyclerView up or down that animation get out of screen, it will stop and you should set up the animation whenever it attached to windows and it decreases the performance.

The final solution to this problem was Webp. Webp is a format that was created by google and you can use it in Android with the Fresco library, and use webp animated images. The library has no problem of transparency and is very high performance, actually animation size is lower than a Lottie animation!

Here is my code to call the Fresco library:

 DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(yourUri)
            .setAutoPlayAnimations(true)
            .build();

and easily set controller to SimpleDraweeView:

simpleDraweeView.setController(controller);
TylerH
  • 20,799
  • 66
  • 75
  • 101
0

Try putting the recyclerview inside a NestedScroll View, and in the recyclerView put, nestedscrollingEnabled = false.

TylerH
  • 20,799
  • 66
  • 75
  • 101