3

I currently write a react native application,

And I want to show 2 image at the top of my component, So I use my image with:

resizeMode:'contain'

Ah it works, but when I use it, it create a subcontainer and create a marge between the top of my component and my image

How I can remove this space ?

I have tried to remove the size of the space, but it don't works on all devices ...

  • You could use `resizeMode: 'cover'`, but you would lose a part of your image. A better option, but more complicated, would be to set the height of your image according to the current width in order to keep the same ratio as your original image. – Antoine Grandchamp May 22 '17 at 15:37
  • @AntoineGrandchamp Thanks for your reply this is what is currently made actually but if I set the height, it looks like a little different between devices, I'm very intresting because I think there no way to do what I want exactly –  May 22 '17 at 18:19
  • What you can do is use [Dimension.get('window')](https://facebook.github.io/react-native/docs/dimensions.html#get) to get the width of the view. Then, if you know that your original image dimensions are 500 x 250, and the view's width is 400px for exemple, you can then set your heigth to 200px. – Antoine Grandchamp May 22 '17 at 19:41

0 Answers0