我想使用绝对位置在图像上显示文本。但是,由于每个设备的屏幕尺寸不同,因此很难确定确切的位置。
有没有办法计算出准确的位置?
我发布了一个类似的问题,但我没有得到我想要的答案。 我的第一个问题
下面是我尝试过的代码。
<ImageBackground
source={require("../../assets/brain/ohi.png")}
style={{ width: "100%", height: "100%", position: "relative" }}
resizeMode="contain"
onLayout={(event) => this.setLayout(event.nativeEvent.layout)}
>
<Text
style={{
position: "absolute",
left: windowWidth * 0.22,
top: windowHeight * 0.4,
}}
>
Text_1
</Text>
<Text
style={{
position: "absolute",
left: 280,
top: 300,
}}
>
Text_2
</Text>
</ImageBackground>