Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Height not calculated based on screen width in Jetpack Compose #2264

Closed
sergey-shevtsov opened this issue Mar 15, 2023 · 1 comment · Fixed by #2437
Closed

Height not calculated based on screen width in Jetpack Compose #2264

sergey-shevtsov opened this issue Mar 15, 2023 · 1 comment · Fixed by #2437

Comments

@sergey-shevtsov
Copy link

Link to fork with a repro in the issue-repro module
https://github.com/sergey-shevtsov/lottie-android/tree/compose-width-issue/issue-repro-compose

Describe the bug
I have an animation that is wider than the screen width. I need to display it in a scrollable column. The animation should fill the screen width and i expect the height to be calculated in the correct ratio. Actually, the animation is displayed correctly, but takes a height equal to the height specified in the json file.
The reason for this is probably that the Canvas in the LottieAnimation component uses composition.bounds.height() and composition.bounds.width() without any calculation depending on the allowed max width.

Canvas(
  modifier = modifier
    .size((composition.bounds.width() / dpScale).dp, (composition.bounds.height() / dpScale).dp)
) {
...

Steps To Reproduce

  1. Add a raw animation json resource with a size larger than the screen size
  2. Create a Column with verticalScroll modifier
  3. Put a LottieAnimation component with ContentScale.FillWidth on the created column

Expected result:

Actual result:

@aDragovcic
Copy link

Issue is still present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants