- 「React Native」Android title 标题不居
- React Native 打包APK
- react-native flatlist 下拉刷新组件
- React Native在Android当中实践(二)——搭建开
- React Native在Android当中实践(三)——集成到
- React Native在Android当中实践(四)——代码集
- React Native在Android当中实践(五)——常见问
- React Native在Android当中实践(一)——背景介
- 从Android到React Native开发(四、打包流程解析
- 从Android到React Native开发(三、自定义原生控
问题描述
Navigation作导航时,使用
static navigationOptions = ({navigation}) => ({
//...
headerTitleStyle: {
alignSelf: 'center'
},
});
可以使iOS
的title在任何条件下居中显示
但是在Android
上就有点差异
-
无headerLeft和headerRight时
title居中无问题
-
同时存在headerLeft和headerRight时
title居中无问题
-
只有headerLeft或headerRight时
这时,标题会偏向一边
以上headerLeft包括系统添加的返回箭头
解决方案
为headerLeft或headerRight添加一个空视图
static navigationOptions = ({navigation}) => ({
//...
headerTitleStyle: {
alignSelf: 'center'
},
//添加空视图占位
headerRight:<View/>,
});
网友评论