gpt4 book ai didi

javascript - 如何设置Tab.Navigator的背景颜色?

转载 作者:行者123 更新时间:2023-12-02 21:10:47 25 4
gpt4 key购买 nike

正如你在下面看到的,我尝试了很多将背景颜色设置为绿色的方法,但都无济于事。背景像图像一样保持蓝色。

inactiveColoractiveColor 正在工作(分别为白色和红色)。

screenshot

<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",
}

最佳答案

在 React Navigation 6.x 中,您使用 tabBarStyle

<Tab.Navigator
screenOptions={({ route }) => ({
headerShown: false,
tabBarStyle: {
height: 90,
paddingHorizontal: 5,
paddingTop: 0,
backgroundColor: 'rgba(34,36,40,1)',
position: 'absolute',
borderTopWidth: 0,
},
})}
>
<Tab.Screen name="Home" component={Home} />
<Tab.Screen name="List" component={RegistrationList} />
<Tab.Screen name="News" component={News} />
<Tab.Screen name="Profile" component={Profile} />
</Tab.Navigator>

关于javascript - 如何设置Tab.Navigator的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61105084/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com