首页 > 解决方案 > React Native 尝试为文本创建边框

问题描述

我正在尝试为文本创建一个“框”——这意味着一个带有文本边框和背景颜色的边界框(在我的例子中是单个字符)。
但是当我创建一个视图和文本时,文本被视图的上限剪切(看看A是如何被剪切的),我不明白为什么。
我现在的情况

    <View style={styles.container}>
 <Text style={styles.letter} > {character} </Text>
 </View >

export default EStyleSheet.create({
  container: {
    justifyContent: 'center', 
    alignItems: 'center',

  },
  letter: {
    fontSize: 30,
    backgroundColor: 'powderblue',
    borderWidth: 2,
    textAlign: 'center',
    borderColor: 'steelblue',
  },
});

谢谢您的帮助。

标签: reactjsreact-native

解决方案


尝试将margin样式添加到letterand aligSelf: 'center',但实际上我建议将backgroundColorand添加borderWidth<View>样式


推荐阅读