LottieAnimationView height not respecting wrap_content
See original GitHub issueWe have a LottieAnimationView centered vertically on the screen with height wrap_content and a TextView below it.
In v2.0.0 this works as expected. We recently upgraded to v2.3.1 and now the LottieAnimationView is taking up the entire screen, meaning we can’t see the TextView anymore.
This is the xml for both cases. I made the background of the whole layout red and the animation background white to highlight the problem.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="#FF0000">
<!-- Centers animationView & titleView within the available parent space -->
<LinearLayout
android:id="@id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:lottie_autoPlay="true"
app:lottie_fileName="looking-dealers.json"
app:lottie_loop="true" />
<TextView
android:id="@+id/titleView"
style="@style/Title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="54dp"
android:layout_marginLeft="@dimen/margin_m"
android:layout_marginRight="@dimen/margin_m"
android:gravity="center"
android:text="@string/pine_select_dealer_looking_for_dealers" />
</LinearLayout>
</RelativeLayout>
v2.0.0:

v2.3.1:

We have started using some other new features from v2.3.1, so we can’t just go back to v2.0.0. Can you have a look at this issue and/or suggest a workaround until it is fixed?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
Lottie animation is showing as a still image but not playing
I was able to run the animation with the following code: val imageView = view.findViewById<LottieAnimationView>(R.id.image_view) imagView.playAnimation().
Read more >Whole Lottie Love - Novoda Insights
Try to use wrap_content as your LottieAnimationView's width and height. It seems like the view gets clipped in unpredictable ways when ...
Read more >Author: siddharthmakadiya - androidtutorial - WordPress.com
android:layout_height="wrap_content" ... Log.i("huangssh", "Animation resources do not exist");. return; ... setAnimation(animation, LottieAnimationView.
Read more >Using Lottie Android · Lottie Documentation - salihabdul-karim1
The simplest way to use it is with LottieAnimationView: <com.airbnb.lottie. ... android:layout_width="wrap_content" android:layout_height="wrap_content" ...
Read more >Android – Lottie animation slow android - iTecNote
LottieAnimationView android:id="@+id/lottie_view" ... With the width="match_parent", height="wrap_content" combination, the images will be scaled up.
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

android:adjustViewBounds=“true” might be what you’re looking for.
@gpeal Thanks for looking into it and for the detailed explanation 👍