文本的第二行不在行的中心呈现

Luc*_*irl 4 text react-native

我的 样式有问题Text,我有两行 ,Text文本的第一行在行的中心显示正确,但代码的第二行不在中心。如何解决?

<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }}>
  <Text
    style={{ marginLeft: 5, fontWeight: '500', fontFamily: 'Arial', fontSize: ratio * 14, color: '#3c3c3c' }}
    numberOfLines={2} > {title}
  </Text>
</View>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

Aji*_*ian 8

你需要使用textAlign:'center'

   <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
        flexDirection: "row"
      }}
    >
      <Text
        style={{
          textAlign:'center', //Added
          marginLeft: 5,
          fontWeight: "500",
          fontFamily: "Arial",
          fontSize: ratio * 14,
          color: "#3c3c3c"
        }}
        numberOfLines={2}
      >
        {title}
      </Text>
    </View>
Run Code Online (Sandbox Code Playgroud)