lottie-react-native: Size of lottie animations don't fill up the container
It seems the animations from .json require excessive padding/margins to be viewable:

import Animation from 'lottie-react-native';
// a bunch of other code
<Animation
style={{
backgroundColor: 'red',
width: 100,
height: 100,
resizeMode: 'contain',
}}
source={lottieLoader}
progress={this.state.progress}
/>
This doesn’t show up in the container, however if I add excessive padding it does:

import Animation from 'lottie-react-native';
// a bunch of other code
<Animation
style={{
backgroundColor: 'red',
width: 100,
height: 100,
paddingTop: 100,
paddingRight: 300,
resizeMode: 'contain',
}}
source={lottieLoader}
progress={this.state.progress}
/>
Using the following share animation: https://www.lottiefiles.com/search?q=share
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16
@arjunpola Above is solution for you
aghhh I thought that was the issue but was hoping there was a way to get rid of the empty padding, that’s crazy how on earth would we then scale it to zoom and properly position itself amongst our other icons/textfields.
I can’t seem to get the animation itself to fit in it’s parent view edge to edge, which makes it hard to position them side by side:
the red background is TouchableOpacity which is 100x100, but the ticket itself has way too much padding on the inside, and makes it basically impossible to line these up as a list.
Use aspectRatio in Lottie styles as aspectRatio: deviceWidth/deviceHeight
@monotv, try Keyshape
Googling for a similar error brought me here. I also saw my animation being displayed outside the container. Wrapping the <Animation> in a <View> fixed it for me in the end. e.g: