我正在构建一个制作邀请卡的应用程序,我正在使用 ImageBackground 制作卡片,然后对其中的内容进行样式设置,但是我遇到了不同屏幕尺寸和分辨率的问题,我的代码如下:
<ImageBackground
resizeMode='contain'
backgroundColor={this.state.bgColor}
style={{
height: height / 3 + 20,
width: width,}}
source={this.state.border}>
<View style={{ flex: 1, marginRight: 10,
marginLeft: 45, marginTop: 10 }}>
<Text style={{ fontSize: height / 37,
color: this.state.fontColor,
fontWeight: '700',
textAlign: 'center',
fontFamily: this.fonttext }}>{this.type}</Text>
<Text style={{ marginLeft: 40,
marginRight: 5, marginTop: 10,
fontSize: height / 48,
color: this.state.fontColor,
textAlign: 'right',
fontFamily: this.fonttext }}>{this.body}</Text>
<Text style={{ fontSize: height / 49,
marginTop: 10,
color: this.state.fontColor,
textAlign: 'right',
fontFamily: this.fonttext }}>{this.location}</Text>
<View style={{ alignItems: 'center',
justifyContent: 'center',
marginTop: (height / 3 + 10) / 11 }}>
<Text style={{ fontSize: height / 49,
fontWeight: 'bold',
color: this.state.fontColor,
textAlign: 'right',
fontFamily: this.fonttext }}>From</Text>
<Text style={{ fontSize: height / 49,
color: this.state.fontColor,
textAlign: 'right',
fontFamily: this.fonttext }}>{this.fromD}</Text>
</View>
<Text style={{ fontSize: height / 55,
color: this.state.fontColor,
textAlign: 'right',
fontFamily: this.fonttext }}>{'*' + this.notes}</Text>
</View>
</ImageBackground>
它在 Iphone 6 上运行良好
但是在 Iphone x、8 plus 和 android 设备上,视图会发生变化,并且背景图像从上方和左侧都有一些边距,尽管我使用了尺寸,所以我可以获得屏幕的高度和宽度,所以我可以设置相应地查看但没有工作,所以在这种情况下最好的做法是什么,以便所有设备上的视图都相同。