Closed maakle closed 6 years ago
try as below:
style={[StyleSheet.absoluteFill, {someOtherStyles}]}
Okay I solved it. So what I had to do is go on step deeper where the animation is (not the class of the screen). I had to align the Lottie Loading animation (animationWrapper
) to it's higher wrapper (imageWrapper
). My Loading class with the animation looks something like this. The other class basically stayed the same. I hope this helps someone!
// all imports
import ..., { ... };
var styles = StyleSheet.create({
imageWrapper: {
width: 170,
height: 170,
opacity: 0.85,
},
loadingText: {
width: '100%',
textAlign: 'center',
},
logoImage: {
width: '100%',
alignItems: 'center',
},
animationWrapper: {
width: '100%',
height: '100%',
},
});
export default class Loading extends Component {
static propTypes = {
text: PropTypes.string,
}
componentDidMount() {
this.animation.play();
}
render() {
const loader = EXPLICIT_DATA_COLLECTION ? MyLoadingAnimation : LoadingAnimation;
return (
<ScreenWrapper style={{ alignItems: 'center' }}>
<StandardWrapper style={styles.imageWrapper}>
<Animation
ref={animation => { this.animation = animation; }}
style={styles.animationWrapper}
source={loader}
loop
/>
</StandardWrapper>
<PrimaryText style={styles.loadingText}>
{this.props.text}
</PrimaryText>
</ScreenWrapper>
);
}
};
what are StandardWrapper and ScreenWrapper? simple View's ?
I already asked this question on Stackoverflow but seems like nobody was able to help me there. (https://stackoverflow.com/questions/48070527/not-able-to-center-lottie-animation-and-text-in-screen-react-native)
How is it possible to center both a text and an animation from lottie? My loading animation is a bit cut of to the right side. I tried to following here but it didn't work https://github.com/airbnb/lottie-react-native/issues/143
My class looks like this:
And the screen looks like this. So you can see that the animation is a bit cut of to the right. Also without the height and width = 300 it is very to the right shifted.