【发布时间】:2018-08-21 08:20:48
【问题描述】:
如何在 React Native 中将文本垂直放置在图像上? I found this doc。但我不能那样做,我不能将text标签添加为Image标签的子组件。我试过如下。
<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'
},
});
【问题讨论】:
标签: javascript image react-native jsx