LottieAnimation not displaying in @Preview

Viewed 22

My LottieAnimation is not showing inside of a jetpack compose @Preview fun. It works fine when running on an actual device.

@Preview
@Composable
fun LottiePreview() {
    MaterialTheme {
        Surface {
            Column {
                Text(text = "Above lottie")

                val composition by rememberLottieComposition(LottieCompositionSpec.RawRes(R.raw.no_receipts))
                LottieAnimation(
                    composition = composition,
                )
                
                Text(text = "Below lottie")
            }
        }
    }
}

enter image description here

I've tinkered with different settings and constructors but haven't been able to get the preview to work - I also have been unable to find any documentation or open issues on this. Am I just missing something obvious to get lotties working in previews?

1 Answers

Animations don't work on the static previews. You need to tap on that button with a finger with waves on the tips (right after the label "LottiePrevi..."), so you'll be able to see animations running, and also interact with the composables.

Related