I want to show the spinner at the center of screen.I used alignItems, justifyContent and flex but there is no change in the position then i use margintop for correct positioning.why there is no change on the use of alignItems,justifyContent and flex?
here i m using spinner.
 return (
  <View style={style.spinnerStyle}>
  <Spinner size ="large" />
  </View>
 );
 const style = {
spinnerStyle: {
  flex: 1,
  marginTop:240
}
};
Spinner.js
  import React from 'react';
  import {View,ActivityIndicator} from 'react-native';
  const Spinner = ({size}) => {
  return (
  <View style = {styles.spinnerStyle}>
  <ActivityIndicator size={size || 'large'} />
  </View>
  );
 };
const styles = {
spinnerStyle: {
flex: 1,
justifyContent: 'center',
alignItems:'center'
 }
 };
export { Spinner };
Can you please try with following:
where you are using Spinner
spinnerStyle: {
    flex: 1,
    marginTop:240,
    justifyContent: 'center',
    alignItems:'center'
}
In Spinner
spinnerStyle: {
    flex: 1
    alignSelf:'center'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With