airbnb / lottie-android

Render After Effects animations natively on Android and iOS, Web, and React Native
http://airbnb.io/lottie/
Apache License 2.0
34.97k stars 5.4k forks source link

Scale best practice #668

Closed lawloretienne closed 6 years ago

lawloretienne commented 6 years ago

Is it best practice to have a different dimension for the app:lottie_scale attribute? Right now i have a dimension declared in a dimens.xml file that is in /values-hdpi, /values-xhdpi, /values-xxhdpi, /values-xxxhdpi. Is that the right approach?

gpeal commented 6 years ago

@lawloretienne You shouldn't ever need this. All values in your composition get converted to dps. If you want the animation to be a specific size, just set a fixed size on your LottieAnimationView and use scaleType="centerInside" or centerCrop

lawloretienne commented 6 years ago

But if this ends up clipping the lottie animation it is not what our designers had intended.

gpeal commented 6 years ago

@lawloretienne it won't if you use centerInside

waqarv712 commented 4 years ago

centerCrop only works with width="wrap_content" and height="wrap_content" not with fixed width and height.

Hamzaelkhatri commented 4 years ago

@waqarv712 it works perfectly with fixed width and height just add lottie_scale="0.1".

pejman-74 commented 3 years ago

Is there a similar way in jetpack compose?

gpeal commented 3 years ago

@pejman-74 I'm going to add a scaleType parameter soon but you should be able to achieve pretty much whatever you want with the modifier parameter's size modifiers already.

pejman-74 commented 3 years ago

I did not find a way, I want to put an animation in the background with (fillMaxSize) but it does not fill it.

gpeal commented 3 years ago

@pejman-74 You'll have to wait for the scaleType update to get it out of the box then. You also use the Compose transform/scale modifiers to add your own scale.