我创建了一张卡片,其父组件即卡片是一个 Flex。所以使用 alginSelf 后: 'stretch'
代码:
<View style={styles.card}>
<Image source={require('./Images/facility/facility.png')} style={styles.imgFacility}></Image>
<TouchableHighlight>
<Text style={styles.title}>Barasti /</Text>
</TouchableHighlight>
</View>
CSS:
card: {
flex: 1,
paddingLeft: 16,
paddingRight: 16
},
imgFacility: {
height: 200,
alignSelf: 'stretch'
},
title: {
color: '#ff3385'
}
上面的代码 alginSelf: 'stretch'
不起作用,为什么会这样?可能是什么原因?
查看截图:
最佳答案
如果您希望图像为全宽,请像这样更改您的 imgFacility 样式:
imgFacility:{
width: Dimensions.get('window').width,
height: 200,
alignSelf: 'center'
}
关于javascript - 如何拉伸(stretch)不适用于 native 图像的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52484126/