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.

Animation max size

See original GitHub issue

I have animation with following spec:

  "v": "4.5.6",
  "fr": 25,
  "ip": 0,
  "op": 38,
  "w": 360,
  "h": 146,
  "ddd": 0,
.......

I want to achieve behavior when animation view fits on screen width. If i set to LottieAnimationView layout_width=“match_parent” and layout_height=“wrap_content” i faced with following issue on phones: if phone’s width is 1440px(samsung s7), animation viewport width is 1000px because of LottieComposition MAX_PIXELS = 1000 constraint. So i got space between animation and screen edge. I solved this issue by dynamically changing view height to proper value:

DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
		float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
		float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
		mLottieAnimationView.getLayoutParams().height = (int) (displayMetrics.density * 146f / (360f / dpWidth));

After applying new height on view, animation viewport fits screen width well. So my question is this fix save in terms of stability and performance? PS: i don’t have masks or mattes.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
gpealcommented, Mar 16, 2017

Use centerCrop instead of center.

On Thu, Mar 16, 2017, 3:54 AM Michael notifications@github.com wrote:

I think I face the same issue. My layout:

<LinearLayout android:background="#00ffffff" android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_gravity="center" android:scaleType="center" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>

And I set this into a view with a fixed width that is higher than the file width. The LottieAnimationView fills out the whole space (setting a background color to prove it) but the animation is still small in the middle of the view. A “autoScale” switch would be nice to have it fill up the space

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/airbnb/lottie-android/issues/112#issuecomment-287022570, or mute the thread https://github.com/notifications/unsubscribe-auth/ABP0Yde3C9a6_j7Q-657RR-n2x6txpBWks5rmRTMgaJpZM4MDPiu .

0reactions
AndrewLotarcommented, Dec 11, 2022

I set up width in dp that’s equal to device width and it scale perfectly good. It doesn’t work same with android:layout_width="match_parent".

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the maximum size of animation I can upload to ...
At the moment, the maximum size for an animation can be uploaded to LottieFiles is 35kb.
Read more >
How long can a GIF animate? Are there any time restrictions ...
Uploads are limited to 15 seconds, although we recommend no more than 6 seconds. Uploads are limited to 100MB, although we recommend 8MB...
Read more >
Google Ad Manager creative requirements - Display & Video ...
Animation length must be 30 seconds or shorter, and animated GIF ads must have a framerate of 5 frames per second or slower....
Read more >
What Is The Maximum Image Size For Use In A GIF? - 12854162
I have no personal experience with animated GIFs, but I have found this from Google: ... "The maximum size of image and GIF...
Read more >
Preview animations created with a larger frame range set at ...
Preview animations are limited to 1GB in file size when using AVI and MOV file formats. Solution: To solve issues with incomplete movie...
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