【问题标题】:Header text not showing in center标题文本未显示在中心
【发布时间】:2018-11-13 06:35:56
【问题描述】:

我是原生反应的新手。我正在研究导航。问题在于标题文本没有进入中心。我试过这个

static navigationOptions = {
title: "Help",
alignSelf: 'center',
marginLeft: 50,
 headerLayoutPreset: 'center',
textAlign: 'center',
justifyContent:"center",

headerStyle: {
   backgroundColor: '#a01b1b',
   textAlign: 'center',
   headerLayoutPreset: 'center',
   justifyContent:"center",

  },

【问题讨论】:

    标签: reactjs react-native npm navigation


    【解决方案1】:

    设置headerTitleStyle 如下所示,将您的标题设置在标题的中心

            navigationOptions: {
                title: 'Help',
                headerTitleStyle: {
                    flex: 1,
                    textAlign: 'center',
                    fontFamily:'Lato-Black' //for setting font
                },
                headerStyle: {
                    backgroundColor: '#a01b1b', //set style to set backgroundColor to full header
                },
                headerBackTitle: 'Login',
                headerRight: <View/> //If you have back arrow at headerLeft otherwise remove this line
            }
    

    【讨论】:

    • 再问一个问题,我想用不同的字体为文本命名,我该怎么做?
    • 现在我得到的只是我设置背景颜色的一件事,但它只显示帮助文本而不是整个标题。
    • 查看编辑后的答案集style对象设置backgroundColor
    • @shabnamsingh 刚刚编辑了我的答案集headerStyle 而不是style
    • 我没有得到字体。只是最后一个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 2022-01-09
    • 1970-01-01
    • 2011-01-01
    • 1970-01-01
    • 2020-06-26
    相关资源
    最近更新 更多