Is there a way to vertically align text over an image in react native? I came across this helpful guide, but I encountered difficulties trying to implement it. Specifically, I couldn't figure out how to nest the text
tag within the Image
tag. Below is my attempt:
<Card>
<CardSection>
<View style={styles.container}>
<Image source={require('../Images/4.jpg')} style={styles.imageStyl} />
<Text style={styles.userStyle}>
{this.props.cat.name}
</Text>
</View>
</CardSection>
</Card>
const styles = StyleSheet.create({
container:{
flex: 1,
alignItems: 'stretch',
justifyContent: 'center',
},
imageStyl: {
flexGrow: 1,
width: "100%",
height: 200,
alignItems: 'center',
justifyContent: 'center',
},
userStyle:{
fontSize: 18,
color: 'black',
fontWeight: 'bold',
textAlign: 'center'
},
});
Any suggestions on how to center the text within the image as shown in this example image?