Rocky
Rocky

Reputation: 31

Put image on top of image React Native

I have a image in my component and I am trying to place an image on top of that. But only the first image shows, the one I am trying to place on top of it doesn't.

Upvotes: 2

Views: 4055

Answers (3)

Mr. Stark
Mr. Stark

Reputation: 1

You need to give ImageBackground & then give Image

<ImageBackground>
<Image></Image>
</ImageBackground>

like this

Upvotes: 0

hyb175
hyb175

Reputation: 1291

React Native supports zIndex. You can give your second image a style like this { zIndex: 1, position: 'absolute', ... // other position style } to put it on top of other view. See https://facebook.github.io/react-native/docs/layout-props.html#zindex for reference.

Upvotes: 3

gaback
gaback

Reputation: 638

Put the second Image inside the first one:

<View style={Styles.container}>
    <View style={Styles.viewStyle}>
        <Image
            style={Styles.imageStyle}
            source={require('./Bakgrundsbild.png')} >
            <View style={Styles.logoViewStyle}>
                <Image
                    style={Styles.logoStyle}
                    source={require('./Logo.png')}
                    />
            </View>
         </Image>
     </View>
</View>

Upvotes: 0

Related Questions