有人知道如何抛出这个恼人的背景色时,标签是活跃的?我尝试了很多解决方案,但我仍然有问题
function TabsAndroid() {
return (
<TabAndroid.Navigator
sceneAnimationEnabled={true}
barStyle={{ backgroundColor: colors.primary }}
screenOptions={({ route }) => ({
tabBarIcon: ({ color, focused }) => {
let iconStr: string = "";
if (route.name === "Tab1")
return (
<Image
source={{
uri: "https://imgs.search.brave.com/70390jQSfVsjPzoOaHb96nE2lssrdYkr0HOVLKagutE/rs:fit:1024:1024:1/g:ce/aHR0cDovL2ljb25z/Lmljb25hcmNoaXZl/LmNvbS9pY29ucy9w/YW9tZWRpYS9zbWFs/bC1uLWZsYXQvMTAy/NC9zb2NpYWwtZmFj/ZWJvb2staWNvbi5w/bmc",
}}
style={{ width: 10, height: 20 }}
/>
);
if (route.name === "Tab2") iconStr = "T2";
if (route.name === "StackNavigator") iconStr = "Stack";
return <Text style={{ color }}>{iconStr}</Text>;
},
})}
activeColor="#fff"
inactiveColor="#ccc"
>
<TabAndroid.Screen
name="Tab1"
options={{ tabBarColor: "red" }}
component={Tab1}
/>
<TabAndroid.Screen name="Tab2" component={Tab2} />
<TabAndroid.Screen name="StackNavigator" component={MyStack} />
</TabAndroid.Navigator>
);
}
我尝试了最老的解决方案,我只得到改变文本颜色时,用户点击标签,但没有为图标
1条答案
按热度按时间41zrol4v1#
您需要在screenOptions中更改背景颜色。
https://reactnavigation.org/docs/bottom-tab-navigator/#screenoptions 这个: