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.

LottieAnimationView height not respecting wrap_content

See original GitHub issue

We 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 0 0

v2.3.1: 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

15reactions
mase7569commented, Jul 15, 2021

android:adjustViewBounds=“true” might be what you’re looking for.

0reactions
andersucommented, Jan 30, 2018

@gpeal Thanks for looking into it and for the detailed explanation 👍

Read more comments on GitHub >

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

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