Reputation: 1727
I have created a card and the parent component i.e card is a flex. So after using alginSelf: 'stretch'
Code:
<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'
}
Above code alginSelf: 'stretch'
is not working why so ? What could be the reason ?
See screenshot:
Upvotes: 2
Views: 829
Reputation: 571
If you want your image to be full width,change your imgFacility style like this:
imgFacility:{
width: Dimensions.get('window').width,
height: 200,
alignSelf: 'center'
}
Upvotes: 1
Reputation: 1727
alignSelf:'stretch
doesn't work in above case because there should be a block element to stretch.
So below code works perfectly:
imgFacility: {
height: 200,
width: '100%'
}
Upvotes: 1