Monday, 8 July 2019

React Native Image resizeMode stretch or contain not working (only cover working)

I've got a React Native app where I'm trying to display a shadow below a view by stretching an image (loaded locally). I've just made a lame PNG image for the shadow. I'm trying to attach it below my actual view and stretch according to the view size with the style:

position:'absolute',
width:'100%', 
height: '100%', 
left: 0,
top: 0,
resizeMode:'stretch', 

The image view itself is correctly laid out, though the image inside it doesn't resize correctly. If the resize mode is stretch or contain, the image becomes invisible (though the image view displays correctly, I've set a background color to the image view to debug that and it displays the background color in the correct layout). The image is displayed only if resize mode is cover, which is not what I want. I've tried setting the resize mode both in style and as a prop, results are identical.

PS: I'm trying to get shadows working on Android so shadow styles don't work, elevation is not customizable by any means, and react-native-shadow never worked correctly for me and messed up the whole layout, so that's why I'm going with the "image way".

Why isn't resize mode working correctly? (I'm on RN 0.59.9)



from React Native Image resizeMode stretch or contain not working (only cover working)

No comments:

Post a Comment