react-native - 如何使指示器覆盖选项卡而不是相反
问题描述
了解 reactnative 并知道如何使用 reactnavigation 的人。
我正在创建一个开源应用程序,并在其上使用 MaterialTopTabNavigator。当我对选项卡和指示器进行样式化时(使用 indicatorStyle 和 tabStyle),选项卡会覆盖指示器,使其不可见。有人知道如何解决吗?我想让指示器覆盖选项卡,而不是相反
GitHub 仓库:https : //www.github.com/arthrc/packly src/route.js 第 30~49 行
export default function Routes() {
return (
<Tab.Navigator
initialRouteName='Home'
tabBarOptions={{
activeTintColor: '#fff',
inactiveTintColor: '#f7f7f7',
tabStyle: { backgroundColor: '#a500ff'},
indicatorStyle: {
height: 6,
bottom: -3,
backgroundColor: '#D70CE8',
width:100,
},
labelStyle: {
fontFamily: 'Inter_600SemiBold',
fontSize: 16
}
}}
>
解决方案
我只是改变了tabStyle
它 style
,它工作得很好
最终代码:
export default function Routes() {
return (
<Tab.Navigator
initialRouteName='Home'
tabBarOptions={{
activeTintColor: '#fff',
inactiveTintColor: '#f7f7f7',
tabStyle: { backgroundColor: '#a500ff'},
indicatorStyle: {
height: 6,
bottom: -3,
backgroundColor: '#D70CE8',
width:100,
},
labelStyle: {
fontFamily: 'Inter_600SemiBold',
fontSize: 16
}
}}
>
推荐阅读
- nexus - 我应该将哪种存储库格式与 Sonatype Nexus 一起用于非通用构建输出?
- c - CSFML顶点数组和绘图
- python - 返回字符串“hi”出现在给定字符串中任意位置的次数——Python codingbat问题
- angular - 组件构造函数中的依赖注入
- python - 如何解决“找不到命令错误”。在 cmd 提示符下给出 spyder3 命令时
- c++ - 一键注册两次 C++ / GLUT
- javascript - 如何依次调用 Web 服务端点?
- node.js - Express 服务器没有安装在我的机器上
- c# - 在 Unity 中使用心脏的卫生系统
- python - 如何解决 PyTorch 堆栈的问题?