lottie-android
lottie-android copied to clipboard
[Bug] Afterimage Persists in Android
LottieAnimationView's Parent View After Applying Alpha Animation
When changing the visibility of the LottieAnimationView during the animation of the parent view, the animation pauses, but the view itself continues to linger on the screen as an afterimage.
When the visibility is set to 'gone,' and a layout inspection is performed, the view appears to be removed, but an afterimage persists.
xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
<FrameLayout
android:id="@+id/lottieParentView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottieView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_rawRes="@raw/loading_spinner_w_30" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
code
binding.lottieParentView.animation = AlphaAnimation(0.5f, 1f)
.apply {
// after 10second animation done
duration = 10000
setAnimationListener(object : AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
toast("End Alpha Animation")
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
}
binding.lottieParentView.postDelayed(3000) {
binding.lottieParentView.isVisible = false
toast("Exec lottieParentView visible gone")
}
example | layout inspect |
---|---|