Проблема в том, что ваши marginLeft
и marginRight
распространяются через всю панель вкладок.
Вы можете исправить это, введя следующее:
import { Dimensions } from 'react-native';
const width = Dimensions.get('window').width;
const tabBarWidth = width - 30; // Subtract margins from your screen width. In your case 2*15= 30
и обновление вашей вкладки BarOptions:
tabBarOptions: {
activeTintColor: "white",
inactiveTintColor: "blue",
upperCaseLabel: false,
scrollEnabled: false,
inactiveBackgroundColor: "white",
indicatorStyle: {
height: null,
top: 0,
backgroundColor: 'red',
//width:110, remove width here
},
style: {
marginTop: 60, // quick hack for iphone X
marginLeft: 15,
marginRight:15,
borderWidth: 1,
height: 30,
borderColor: "blue",
backgroundColor: "white",
},
tabStyle: {
borderWidth:1,
borderColor:"blue",
justifyContent: "center",
width: tabBarWidth/4, // divided by amount of screens you have
},
labelStyle: {
marginTop: -4
}
}
Как видите, результат работает также, например, с 4 вкладками: