我想实现像instagram一样在设备的全宽度和原始图像高度上显示图像/视频。我该怎么做呢?
将图像的宽度设置为设备宽度,高度设置为设备高度。然后将resizeMode
属性指定为contain
。这将使整个图像适合屏幕。
<Image style={styles.image} source={{ uri: img_url }} />;
图像风格,
const {width, height} = Dimensions.get('window');
image: {
width,
height,
resizeMode: 'contain'
},
或者查看这个Live Snack Example