正如你在下面看到的,我尝试了许多方法将背景颜色设置为绿色,但都没有效果。背景保持与图像一样的蓝色。
inactiveColor和activeColor工作正常(分别为白色和红色)。

<NavigationContainer>
<Tab.Navigator
initialRouteName="HomeScreen"
activeColor="red"
inactiveColor="white"
activeBackgroundColor="green"
inactiveBackgroundColor="green"
style={{ backgroundColor: 'green' }}
tabBarOptions={{
style:{
backgroundColor: 'green'
}
}}
>
<Tab.Screen
name="HomeScreen"
options={{
tabBarLabel: 'Home',
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons name="home" color={color} size={26} />
),
}}
>
{props => <HomeScreen {...props} state={this.state} />}
</Tab.Screen>
<Tab.Screen
name="Files"
component={FilesScreen}
options={{
tabBarLabel: 'Files',
tabBarIcon: ({ color }) => (
<MaterialCommunityIcons name="file" color={color} size={26} />
),
}}
/>
</Tab.Navigator>
</NavigationContainer>package.json
"dependencies": {
"@react-native-community/masked-view": "^0.1.7",
"@react-navigation/material-bottom-tabs": "^5.1.7",
"@react-navigation/native": "^5.1.4",
}发布于 2020-04-09 01:01:39
在这里引用documentation,您需要使用barStyle。
尝试
<Tab.Navigator
initialRouteName="Feed"
shifting={true}
labeled={false}
sceneAnimationEnabled={false}
activeColor="#00aea2"
inactiveColor="#95a5a6"
barStyle={{ backgroundColor: '#ffff' }}发布于 2020-11-06 12:47:42
在react-导航V5中,您可以执行以下操作:
<Tab.Navigator
initialRouteName={'Critic'}
tabBarOptions={{
activeTintColor: '#fff',
inactiveTintColor: 'lightgray',
activeBackgroundColor: '#c4461c',
inactiveBackgroundColor: '#b55031',
style: {
backgroundColor: '#CE4418',
paddingBottom: 3
}
}}
>
<Tab.Screen name="Critic" component={Critic} options={CriticOptions} />
<Tab.Screen name="Urgent" component={Urgent} options={UrgentOptions} />
<Tab.Screen name="Moderate" component={Moderate} options={ModerateOptions} />
<Tab.Screen name="All" component={All} options={AllOptions} />
</Tab.Navigator>
);发布于 2020-04-09 01:02:21
您需要在screenOptions中添加backgroundColor。https://reactnavigation.org/docs/bottom-tab-navigator/#screenoptions尝试以下命令:
<Tab.Navigator screenOptions={{
tabBarOptions: {
style: {
backgroundColor: '#f9f9f9',
},
},
}}>https://stackoverflow.com/questions/61105084
复制相似问题