const dimensions = Dimensions.get('window');
const imageHeight = Math.round(dimensions.width * 9 / 16);
const imageWidth = dimensions.width;
return (
<Image
style={{ height: imageHeight, width: imageWidth }}
/>
);
import {
Image,
Dimensions,
} from "react-native";
const screen = Dimensions.get("window");
Image.getSize(this.state.image_url, (width, height) => {
//full image to screen width (Change screen.width to pixel you want)
let imageWidthRatio = width / screen.width;
let imageHeight = height / imageWidthRatio;
this.setState({ width: screen.width, height: imageHeight });
});
<Image
style={{
width: this.state.width,
height: this.state.height,
alignSelf: "center",
}}
source={{ uri: this.state.image_url }}
/>