小编Dps*_*ers的帖子

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

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

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 中无法居中对齐。请帮忙。提前感谢

javascript android-studio reactjs react-native react-redux

1
推荐指数
1
解决办法
4817
查看次数