react-native headerTitleStyle

问题描述 投票:1回答:1

我正在使用StackNavigator,并尝试将“主题”一词对齐到垂直居中。但是,调整填充和边距似乎没有帮助。我相信这个词的上方空间是为了迎合状态栏。有没有解决的办法? StackNavigator代码如下。

See image

export const MyAppStack = StackNavigator({
  Topic: {
    screen: TopicScreen,
    navigationOptions: {
      title: 'Topic',
      headerStyle: { 
        backgroundColor: 'grey', 
        elevation: null,
        paddingTop: 0,
        height: 10,
        marginTop: 0 },
      headerTitleStyle: {
        paddingTop: 0,
        alignSelf: 'center',
        justifyContent: 'center'
      }
    },
  },
  FlashCard: {
    screen: FlashCardScreen,
    navigationOptions: {
      title: 'Flashcards',
      headerBackTitleStyle: {
        fontSize: 100,
        alignSelf: 'center'
      }
    },
  },
});

我也附上标题样式(顶部)供参考,但我不认为问题在于它。提前致谢!

const Header = (props) => {
  const { textStyle, viewStyle } = styles;

  return (
    <View style={viewStyle}>
      <Text style={textStyle}>{props.headerText}</Text>
    </View>
  );
};

const styles = {
  viewStyle: {
    backgroundColor: '#ff8a00',
    justifyContent: 'center',
    alignItems: 'center',
    height: 60,
    paddingTop: 15,
    shadowColor: '#000',
    shadowOffset: { width: 0, height: 2 },
    shadowOpacity: 0.2,
    elevation: 2,
    position: 'relative'
  },
  textStyle: {
    fontSize: 20
  }
};
react-native react-navigation
1个回答
0
投票

删除alignSelf:'中心'来自......

headerTitleStyle: { paddingTop: 0, alignSelf: 'center', justifyContent: 'center' }

© www.soinside.com 2019 - 2024. All rights reserved.