您可以按以下方式操作:
<View style={{flexDirection: "column", justifyContent: "space-around",
alignItems: "center", flex: 1, paddingTop: 30, paddingBottom: 30}}>
<TopElement style={{position: "absolute", top:5}}/>
<Image resizeMode="contain" style={{flex: 1}} key={1}/>
...
<Image resizeMode="contain" style={{flex: 1}} key={n}/>
<BottomElement style={{position: "absolute", bottom:5}}/>
</View>
-
使用
paddingTop
&
paddingBottom
在父项上
<View />
,高度为
<TopElement />
和
<BottomElement />
. 使顶部/底部不会与图像重叠。
-
设置
<Image />
道具
resizeMode
到
'contain'
. 使图像在保持原始纵横比的情况下自动调整大小。