【问题标题】:How to edit style of React native tabs in a tab navigation display如何在选项卡导航显示中编辑 React 本机选项卡的样式
【发布时间】:2021-08-11 06:42:16
【问题描述】:

如何在标签导航显示中编辑 React 原生标签的样式,使其看起来像这样

现在标签只在 android light 模式下看起来像上图 但是当我将手机的主题切换到 android 上的深色主题时,它看起来像这样

这是不好的,不是我想要的显示方式

在下面查看我的代码

//AuthTabs.js
import 'react-native-gesture-handler';
import React from 'react';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';

import SignIn from './tabs/SignIn';
import SignUpPhoneVerify from './tabs/SignUpPhoneVerify';
const Tab = createMaterialTopTabNavigator();

export default function AuthTabs() {
  return (
    <Tab.Navigator>
      <Tab.Screen
        name="SignIn"
        component={SignIn}
        options={({navigation}) => ({
          tabBarLabel: 'Login',
          activeTintColor: '#fff',
          inactiveTintColor: 'ffffff',
          activeBackgroundColor: '#ffffff',
          inactiveBackgroundColor: '#ffffff',
          style: {
            backgroundColor: '#CE4418',
          },
        })}
      />
      <Tab.Screen
        name="SignUpPhoneVerify"
        component={SignUpPhoneVerify}
        options={({navigation}) => ({
          tabBarLabel: 'Register',
          activeTintColor: '#fff',
          inactiveTintColor: 'ffffff',
          activeBackgroundColor: '#ffffff',
          inactiveBackgroundColor: '#ffffff',
          style: {
            backgroundColor: '#CE4418',
          },
        })}
      />
    </Tab.Navigator>
  );
}

【问题讨论】:

  • 黑暗主题是否也保持不变?

标签: android react-native


【解决方案1】:

你可以覆盖像here这样的黑暗主题

【讨论】:

  • 当我按照你说的做时,看到我不断收到的错误-----错误错误:看起来你已经在另一个里面嵌套了一个'NavigationContainer'。通常,您只需要一个位于应用程序根目录的容器,因此这可能是一个错误。如果这是故意的,请明确传递 'independent={true}'。请注意,这将使子导航器与父导航器断开连接,您将无法在它们之间导航。--- 当我通过 'independent={true}' 时,我的导航到新屏幕不起作用,例如:当用户登录
  • 你检查过我的展览样品了吗,它按预期工作。
  • 您的示例没有使用真实的屏幕组件。我的代码确实如此,并且我告诉您您的代码示例使我的项目出现的错误。谢谢,但除非你使用真正的屏幕组件,否则你的代码并没有解决我遇到的问题
  • 真实屏幕元素是什么意思?
  • 我的意思是导出的屏幕
猜你喜欢
  • 1970-01-01
  • 2022-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-18
  • 2020-06-16
  • 1970-01-01
相关资源
最近更新 更多