Reputation: 21
Its a dumb question but I am having problem that I am trying to fit image into its container. The Image OverFlows in width:
Code :
<View style = {styles.imageContainer}>
<Image style={styles.img} source={require('./img_1.png')} />
</View>
<View style={styles.banner}>
<ScrollView >
<Text>Hellp Boy</Text>
<Text>Hellp Boy</Text>
<Text>Hellp Boy</Text>
</ScrollView>
</View>
and Styling Portion :
const styles = StyleSheet.create({
imageContainer: {
backgroundColor : '#DB7093',
flex : 1,
padding : 10,
borderColor : '#7FFF00',
borderWidth : 10,
},
img : {
flex : 1 ,
resizeMode : 'stretch',
overflow : 'visible',
},
banner:
{
flex : 2,
padding : 10,
borderColor : '#7FFF00',
borderWidth : 10,
},
});
Upvotes: 1
Views: 4343
Reputation: 92
try putting transform: [{ scale: 1.0 }],
on your imageContainer
Upvotes: 0
Reputation: 7106
Try adding resizeMode='contain'
as a prop to your image :
<Image style={styles.img} source={require('./img_1.png')} resizeMode='contain' />
Upvotes: 0