而不是将您的内容包装在<Image>
,我认为你最好将其包装在absolute
定位元素并使其拉伸以覆盖屏幕。
<View style={styles.container}>
<View style = {styles.backgroundContainer}>
<Image source = {require('./img/landing-background.jpg')} resizeMode = 'cover' style = {styles.backdrop} />
</View>
<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>
</View>
var styles = StyleSheet.create({
backgroundContainer: {
position: 'absolute',
top: 0,
bottom: 0,
left: 0,
right: 0,
},
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: 'black',
color: 'white'
}
});