[英]How can i render Text inside image background in react native?
我想在 ImageBackground 组件中呈现一个文本组件。
我尝试的是
<ImageBackground
source={{uri: smartPaperData.backgroundImage}}
resizeMode="contain"
resizeMethod="scale"
style={{
height: '100%',
width: undefined,
backgroundColor: 'yellow',
}}>
<Text>Hello</Text>
</ImageBackground>
通过使用上面的代码,这就是我得到的。 (你可以在左上角看到你好)
我需要 Hello 文本出现在图像的左上角,但文本出现在其他地方。
谁能帮我解决这个问题
宽度完全取决于原始图像大小。 您需要创建具有固定宽度的容器,例如
<View style={{width: '80%'}}>
<ImageBackground
source={{uri: smartPaperData.backgroundImage}}
resizeMode="contain"
resizeMethod="scale"
style={{
height: '100%',
width: '100%',
backgroundColor: 'yellow',
}}>
<Text>Hello</Text>
</ImageBackground>
</View>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.