I want to resize the image to fit my desired width and height and put it in the top. This is my code:
<View style={{ flex: 1 }}>
<Image source={TOP_START_GRAPHIC} style={styles.topStartImage} />
// another contents goes here...
</View>
style:
const styles = StyleSheet.create({
topStartImage: {
resizeMode: "contain",
width: screen.width * 0.6,
height: screen.height * 0.4,
backgroundColor: 'green',
},
})
this is the result: the result
I found out that it happens because I set the resizeMode: "contain" so that it puts the mage in the center. But if I dont set it, the image will be cropped and super zoom like this:
if I don't resize the image
I expect it to be in the top of the screen with the image fully shown like the first image. Can you help me?
Wrap the image inside a View like this ,
After that give styling for this container as ,
This can hold your image in your desired location (In your case center).