As you can see below, I’ve tried many ways of setting the background color to transparent like this (UI required), all to no avail. The background remains grey-ish like the image
<Tab.Navigator screenOptions={{
tabBarShowLabel: false,
swipeEnabled: false,
tabBarShowIcon: true,
tabBarItemStyle: { width: iconwidth },
tabBarStyle: { backgroundColor: 'transparent', paddingBottom: 10},
tabBarContentContainerStyle: {backgroundColor : 'transparent', display: 'flex', justifyContent: 'center', alignItems: 'center'},
tabBarPressColor: '#3C60AA',
tabBarIndicatorStyle: {width: iconwidth , height: 5, backgroundColor: '#3C60AA', borderRadius: 20, marginStart: iconwidth *0.61},
lazy: true,
lazyPlaceholder: () => <POTab_lazy/>
}}>
<Tab.Screen name="POTab_1" component={POTab_1} options={{ tabBarAccessibilityLabel: 'Info',tabBarIcon: ({ tintColor }) => ( <Image source={require('../../assets/icon_info.png')} style={{width: 30, height: 30 }}/>), }}/>
<Tab.Screen name="POTab_2" component={POTab_2} options={{tabBarAccessibilityLabel: 'File',tabBarIcon: ({ tintColor }) => ( <Image source={require('../../assets/icon_file.png')} style={{width: 30, height: 30 }}/>),}}/>
<Tab.Screen name="POTab_3" component={POTab_3} options={{tabBarAccessibilityLabel: 'Attach',tabBarIcon: ({ tintColor }) => ( <Image source={require('../../assets/icon_attach.png')} style={{width: 30, height: 30 }}/>),}}/>
<Tab.Screen name="POTab_4" component={POTab_4} options={{tabBarAccessibilityLabel: 'Link',tabBarIcon: ({ tintColor }) => ( <Image source={require('../../assets/icon_link.png')} style={{width: 30, height: 30 }}/>),}}/>
<Tab.Screen name="POTab_5" component={POTab_5} options={{tabBarAccessibilityLabel: 'Timer',tabBarIcon: ({ tintColor }) => ( <Image source={require('../../assets/icon_timer.png')} style={{width: 30, height: 30 }}/>),}}/>
</Tab.Navigator>
);
}
POTab_1.js code looks like this
<ScrollView showsVerticalScrollIndicator={false}>
<View style={{ flex: 1, justifyContent: 'flex-start', alignItems: 'flex-start', padding: 20 }}>
<View style={{marginBottom: 15}}>
<Text style={{color: 'grey', fontFamily: 'Poppins-Regular', lineHeight: 20}}>Purchase Order</Text>
<Text style={{color: 'black', fontFamily: 'Poppins-Bold'}}>450004892</Text>
</View>
<View style={{marginBottom: 15}}>
<Text style={{color: 'grey', fontFamily: 'Poppins-Regular', lineHeight: 20}}>Vendor id</Text>
<Text style={{color: 'black', fontFamily: 'Poppins-Bold'}}>0003300000</Text>
</View>
<View style={{marginBottom: 15}}>
<Text style={{color: 'grey', fontFamily: 'Poppins-Regular, lineHeight: 20'}}>Vendor Name</Text>
<Text style={{color: 'black', fontFamily: 'Poppins-Bold'}}>ITT Texas</Text>
</View>
<View style={{marginBottom: 15}}>
<Text style={{color: 'grey', fontFamily: 'Poppins-Regular, lineHeight: 20'}}>Item No</Text>
<Text style={{color: 'black', fontFamily: 'Poppins-Bold'}}>00010</Text>
</View>
</View>
</ScrollView>
package.json
@react-navigation/material-top-tabs: "^6.2.2"
react-native-pager-view: "^5.4.25"
react-native-tab-view: "^3.1.1"
2
Answers
If you want to set background color for the whole tab bar, then we need to provide the style in
tabBarOptions
prop to the Tab.Navigator.Consider the following code snippet.
Updated your code to include
tabBarOptions
If you’re trying to change the screens, not the tab bar itself, I found setting
sceneContainerStyle
to be the way to do it: