如何将标题居中而不受反应导航中的headerLeft影响?

时间:2018-10-27 19:48:18

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

我使用反应导航,并且将标题居中放置在栏中,但是它受headerLeft影响, 当我关闭它们时,它可以正常工作并使标题居中, 如何在不影响标题的情况下使用另一个左右按钮\ icon

is not centering

centering when delete the logout button

代码:

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",
       }
    }
  }
 });

1 个答案:

答案 0 :(得分:2)

您的headerTitleStyle道具没有问题,只需确保headerHead和headerRight都具有View。

示例:

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