无法在react-native android中居中对齐标题标题

Dps*_*ers 1 javascript android-studio reactjs react-native react-redux

使用堆栈导航,我通过使其成为子组件来定义标题标题,如下所示

headertitle.js

render(){
   return(
        <View style={{flexDirection:'row',justifyContent:'center'}}>
        <Text style={{fontSize:RF(3),fontWeight:'bold',color:'#fff'}}>XYZ</Text>
        <Text style={{fontSize:RF(3),color:'#fff'}}>ABC</Text>
        </View>
)}
Run Code Online (Sandbox Code Playgroud)

使用此标头的父组件

 static navigationOptions = ({ navigation }) => {
              return {
                headerTitle:(<Headertitle/>),
                headerTitleStyle: {flex: 1, textAlign: 'center'},
                headerRight: (
                  <Icon
                    onPress={navigation.getParam('handleLogout')}
                    name="power-off"
                    type="font-awesome"
                    color="#fff"
                     style={{marginRight:20}}
                    size={RF(4)}
                    backgroundColor="#006DB7"
                  />
                ),

                headerLeft:null
              };
            };
Run Code Online (Sandbox Code Playgroud)

它在 IOS 中运行良好,但在 Android 中无法居中对齐。请帮忙。提前感谢

Soo*_*Koh 5

导航器中有一个新选项

createStackNavigator(routes, { headerLayoutPreset: 'center' })

这是拉取请求:https://github.com/react-navigation/react-navigation/pull/4588