Reputation: 1
I'm trying to create a "box" for a text - meaning a bounding box with border & background color for a text (in my case, a single character).
But when I create a view & text, the text is being cut by the upper bound of the view (look how the A is cut), and I cannot understand why.
My current situation
<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',
},
});
Thanks for the help.
Upvotes: 0
Views: 151
Reputation: 1076
Please try to add padding as i did in below code :
container: {
justifyContent: 'center',
alignItems: 'center',
},
letter: {
fontSize: 30,
backgroundColor: 'powderblue',
borderWidth: 2,
textAlign: 'center',
borderColor: 'steelblue',
padding: 10,
},
});
Upvotes: 0
Reputation: 175
Try to add margin
style to letter
and aligSelf: 'center'
, but actually I'd recommend adding backgroundColor
and borderWidth
to <View>
styles
Upvotes: 1
Reputation: 1917
Remove the border styles from the text and add them to the view.
https://snack.expo.io/HJAihyR9B
Upvotes: 0