【问题标题】:how to centering Title Without being affected by headerLeft in react navigation?如何在反应导航中不受headerLeft影响而使标题居中?
【发布时间】:2019-04-01 05:11:13
【问题描述】:

我使用反应导航,我在栏中将标题居中,但它受到 headerLeft 的影响, 当我关闭它们时,它的工作和标题准确地居中, 如何在不影响标题的情况下使用另一个左右按钮\icon

代码:

const RootNavigator = createStackNavigator({
  Home: {
   screen: Home,
   navigationOptions: {
     title: "Home",
    //headerLeft: null, // here the issue
     headerStyle: {
        backgroundColor: 'rgb(42,55,68)',
     },
      headerTitleStyle: {
         flex: 1,
         textAlign: 'center',
         color: "#fff",
       }
    }
  }
 });

【问题讨论】:

    标签: javascript reactjs react-native react-redux react-navigation


    【解决方案1】:

    headerTitleStyle 道具没有问题,只要确保 headerLeft 和 headerRight 都有一个视图。

    例子:

     headerLeft : (<View><Entypo name='menu' size={28} color='white' onPress={() => navigation.openDrawer()} /></View>),
     headerRight:(<View></View>)
    

    【讨论】:

    • 哦,我没有在路由器文件中导入 React :] 但是现在导航需要更多时间,知道吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-25
    • 2019-07-18
    • 1970-01-01
    相关资源
    最近更新 更多