Ale*_*lex 3 reactjs react-native
Home: {
screen: Home,
headerTitleStyle: {
alignSelf: 'center',
}
Run Code Online (Sandbox Code Playgroud)
HeaderTitleStyle用于代码中的标题样式,但不会生效
我在Android设备上遇到了此问题。搜索了一段时间后,有很多建议可以使用alignSelf: 'center'。但是,它并没有解决。但是我能够通过修复它textAlign: 'center' and flex: 1
您可以在组件中指定navigationOptions:
static navigationOptions = {
headerTitleStyle: { textAlign: 'center', flex: 1 },
};
更新:
最好的解决方案是headerLayoutPreset: 'center'在createStackNavigator()中使用
const MainStack = createStackNavigator({
screen: YourScreen,
navigationOptions: {
title: 'Title'
}
},
{
headerLayoutPreset: 'center'
});
我希望这应该工作:-)
static navigationOptions = {\n headTtle: () => (\n <View style={styles.headerWrapper}>\n <Text\n adjustsFontSizeToFit\n style={styles.headerText}>\xe9\xa6\x96\xe9\xa1\xb5</Text>\n </View>\n )\n}\n\nconst styles = StyleSheet.create({\n headerWrapper: {\n flex: 1\n },\n headerText: {\n textAlign: 'center', // ok\n alignSelf: 'center', // ok\n }\n});\nRun Code Online (Sandbox Code Playgroud)\n\n这样就可以解决\xef\xbc\x8c了
\n| 归档时间: |
|
| 查看次数: |
1118 次 |
| 最近记录: |