question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lottie Animation Drawable Renders Incorrectly Inside a Floating Action Button on Android 5

See original GitHub issue

loading_animation.zip

I’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): Expected_Result

Actual output (Android 5): Actual_result_os5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
gpealcommented, Aug 10, 2019

@LucianIacob it’s likely a bug on FloatingActionButton but if you set the animation after it is laid out, it works.

1reaction
nangonghuangcommented, Jun 7, 2019

have you set fab size in xml ? maybe you can try

android:scaleType="centerInside"
app:fabCustomSize="50dp"

instead of set layout_width and layout_height

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found