如何在React Native中设置这样的文本?

o2rvlv0m  于 2023-02-05  发布在  React
关注(0)|答案(1)|浏览(129)

我试过textAlign=“center”,但它只将文本居中对齐,但我想将整个文本居中对齐,包括最后一行

<Text
      style={{
         marginTop: 16,
         alignSelf: 'center',
         fontSize: 15,
         width: '75%',
         textAlignVertical: 'center',
         justifyContent: 'center',
      }}>
            Making a luxurious lifestyle accessible for a generous group of
            women is our daily drive.
  </Text>
wn9m85ua

wn9m85ua1#

这里是完整的例子.请阅读有关textAlign属性.

import React, {useState} from 'react';
import { Text, View, StyleSheet, Button } from 'react-native';

const App = () => {
  return (
    <View style={styles.container}>
      <Text
        style={styles.text}>
        Making a luxurious lifestyle accessible for a generous group of
        women is our daily drive.
      </Text>
    </View>
  );
};

export default App;
const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems:"center",
    padding: 8,
    backgroundColor: 'white',
  },
  text:{
      marginTop: 16,
      alignSelf: 'center',
      fontSize: 15,
      textAlign:"center",
      width: '75%',
      textAlignVertical: 'center',
      justifyContent: 'center',
  }
});

相关问题