Reputation: 5326
<Image
style={{
alignSelf: 'center',
flex: 1,
width: '25%',
height: null,
resizeMode: 'cover',
borderWidth: 1,
borderRadius: 75,
}}
source={{uri:'https://facebook.github.io/react/img/logo_og.png'}}
resizeMode="stretch"
/>
https://snack.expo.io/rJCoC9S5-
How would i make the image width 25% of the parent, and the height to whatever that is needed to maintain the original width:height aspect ratio?
Upvotes: 4
Views: 7600
Reputation: 405
Aspect Fill in iOS and Center Crop in Android by these lines of code.
image: { flex: 1, width: null, height: null, resizeMode: 'contain' }
Upvotes: 0
Reputation: 2405
You can edit the style of your image like this:
<Image style={style.image} source={require('.....')} />
const style = StyleSheet.create({
image: {
height: 80,
width: 80,
resizeMode: 'contain'
}
});
contain
is what you are looking for. But there are more options like strech
and cover
.
Upvotes: 14