Lottie-android: Lottie animation not work in RecyclerView item

Created on 22 Oct 2018  路  1Comment  路  Source: airbnb/lottie-android

Hi, I use Lottie 2.7.0 and I have a Recyclerview where each item has a LottieAnimationView that play animation when create. So, when I have 20 items (for example) in my Recyclerview and make scroll, the animation in the first items isstopped. I detect with a AnimatorListener that each item enter in onAnimationCancel () when stop.

The problem is, how to work with Recyclerview when each item has animation and all the animations are executed at the same time? And, how not stop animations when scroll the Recyclerview?

PD: If my ViewHolder has setIsRecyclable (false) the problem is solved, all animations play same time and not stopeed, but the scroll is very slow.

Thanks

Most helpful comment

The solution is overried onViewRecycled() and cancel the animation as:

lottieImage.cancelAnimation()

 val drawable = containerView.videoStatus.drawable
        if (drawable is LottieDrawable) {
            drawable.clearComposition()
        }

Dont edit setIsRecyclable (false)

>All comments

The solution is overried onViewRecycled() and cancel the animation as:

lottieImage.cancelAnimation()

 val drawable = containerView.videoStatus.drawable
        if (drawable is LottieDrawable) {
            drawable.clearComposition()
        }

Dont edit setIsRecyclable (false)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anmolk22 picture Anmolk22  路  3Comments

dpmaycry picture dpmaycry  路  3Comments

dfpalomar picture dfpalomar  路  5Comments

11hhlin1 picture 11hhlin1  路  3Comments

gpeal picture gpeal  路  5Comments