6
イメージをルートノードとして配置し、ビューの背景にしました。しかし、他のすべての画像が見えなくなるようです... プラグインなしで組み込みコンポーネントを使用して画像を背景の上に置く方法はありますか?
次のコードサンプルlanding-background
をバックグラウンドとして使用すると、logo
イメージが表示されますが、背景が削除されている場合のみ表示されます。 Text
がReact Nativeの他の画像の上に画像を配置するには?
<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'
}
});
出来た! –