react-native - 如何在 React Navigation v5 中更改出现在 BottomTab 后面的背景颜色?
问题描述
我想创建带有边框半径的 BottomTab,但在我的选项卡后面出现背景颜色(白色),我不知道如何删除或更改它:
我找到了一个“解决方案”:
tabBarOptions={{
showLabel: false,
activeTintColor: theme.primary,
inactiveTintColor: theme.tintInactiveTabBar,
style: {
backgroundColor: theme.backgroundTabBar,
position: 'absolute',
left: 0,
bottom: 0,
right: 0,
borderTopWidth: 0,
borderTopRightRadius: 10,
borderTopLeftRadius: 10,
height: 60,
elevation: 0,
},
}}
但是set position: absolute还有一个问题:在ScrollViews中看不到所有内容:
我尝试在 te 容器中设置填充或边距,但它不起作用。
解决方案
尝试这个 :
activeBackgroundColor - 活动选项卡的背景颜色,inactiveBackgroundColor - 非活动选项卡的背景颜色。
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
const Tab = createBottomTabNavigator();
function MyTabs() {
return (
<Tab.Navigator tabBarOptions={{
scrollEnabled: true,
activeTintColor: '#3684F6', //'rgb(12,157,197)',
inactiveTintColor: 'black',
indicatorStyle: {
backgroundColor: '#ACACAC',
},
labelStyle: {
fontSize: 16,
color: 'black',
},
activeBackgroundColor: 'white',
inactiveBackgroundColor : 'gray',
style: {
backgroundColor: 'white',
},
statusBarStyle: 'light-content',
}}>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Settings" component={SettingsScreen} />
</Tab.Navigator>
);
}
推荐阅读
- python - 使用 bottle-jwt 装饰器的麻烦(不起作用)
- javascript - angular-chart.js:如何在图表中使用来自变量的动态数据而不是静态值?
- r - R 不会将值作为数字导入
- react-native - 如何从 FlatList 中的存储中删除项目?
- python - 不希望用户输入数字时 Input() 函数出现问题
- mysql - mysql存储函数case语句
- voice-recognition - 对于具有 3 秒长度的音频样本,最佳窗口大小(以秒为单位)和跳跃大小(以秒为单位)是多少?
- python - Python脚本在不同的行停止并且不抛出异常
- c++ - GCC 模板推导消除了 const 错误?
- jquery - JQuery Mapael 在错误位置显示工具提示