relative width and height image react native 1

relative width and height image react native

const dimensions = Dimensions.get('window');
const imageHeight = Math.round(dimensions.width * 9 / 16);
const imageWidth = dimensions.width;

return (
   
);

Here is what the above code is Doing:
1. We’re using the Dimensions API to get the width and height of the device.
2. We’re using the width of the device to calculate the height of the image.
3. We’re using the width and height of the device to set the height and width of the image.

Similar Posts