Lottie Animation Drawable Renders Incorrectly Inside a Floating Action Button on Android 5
See original GitHub issueI’m trying to set a **LottieDrawable** as image drawable for a FloatingActionButton. The problem comes when I try to run the code on an Android 5 device: the animation is not centered within the button as it is in Android >= 6. Somehow it is losing padding or margin. Anyone has an answer for this problem or maybe an workaround?
val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromRawRes(context, R.raw.loading_anim).addListener { lottieComposition ->
lottieDrawable.composition = lottieComposition
lottieDrawable.scale = 0.5F
lottieDrawable.repeatCount = LottieDrawable.INFINITE
lottieDrawable.playAnimation()
}
floatingActionButton.setImageDrawable(lottieDrawable)
Expected output (works correctly on Android 6,7,8,9,Q):

Actual output (Android 5):

Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
kotlin - Lottie Animation Drawable Renders Incorrectly Inside a ...
The problem comes when I try to run the code on an Android 5 device: the animation is not centered within the button...
Read more >How to implement Floating Action Button with Animation in ...
In this tutorial, we are going to create the floating action button with animations without any plugins or third-party libraries.
Read more >AnimatedIcons: Strikethru - Styling Android
In this occasional series we'll look at how to create some of these animations as Animated Vector Drawables which will show some useful...
Read more >Release notes - Proto.io
Fix: The iPhone Notch position was wrong, when previewing the prototype on some Android phones; Fix: Lottie animations where not visible in some...
Read more >How to Control Lottie Animations Programmatically in Android?
Lottie is a mobile library for Android and iOS that parses Adobe After Effects animations exported as JSON with Bodymovin and renders them ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@LucianIacob it’s likely a bug on FloatingActionButton but if you set the animation after it is laid out, it works.
have you set fab size in xml ? maybe you can try
instead of set layout_width and layout_height