我在视图中将一个图片作为根节点以使其成为背景。但是其他所有的图片都变得不可见了...
有没有一种方式可以在不使用插件的情况下,使用内置组件将图片放在背景上面?
在以下代码示例中,landing-background
被用作背景,我的logo
图片是可见的,但仅在去除背景时才会显示。Text
显示在背景上方而没有任何问题...
<View style={styles.container}>
<Image source = {require('./img/landing-background.jpg')}
resizeMode = 'cover' style = {styles.backdrop}>
<View style = {styles.overlay}>
<Text style = {styles.headline}>It should appear in front of the Background Image</Text>
<Image style = {styles.logo} source = {require('./img/logo.png')} />
</View>
</Image>
</View>
var styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
},
overlay: {
opacity: 0.5,
backgroundColor: '#000000'
},
logo: {
backgroundColor: 'rgba(0,0,0,0)',
width: 160,
height: 52
},
backdrop: {
flex:1,
flexDirection: 'column'
},
headline: {
fontSize: 18,
textAlign: 'center',
backgroundColor: 'rgba(0,0,0,0)',
color: 'white'
}
});