Skip to content

Instantly share code, notes, and snippets.

@KanshuYokoo
Created February 25, 2019 15:11
Show Gist options
  • Save KanshuYokoo/a30f7f923ceade4c7b3553f1287a1c85 to your computer and use it in GitHub Desktop.
Save KanshuYokoo/a30f7f923ceade4c7b3553f1287a1c85 to your computer and use it in GitHub Desktop.
Reac-Native: how to place icon images vertical and horizontal centre over background
const { width, height } = Dimensions.get('window')
const sizeStyle = {
width: width,
height: height
}
const styleImage = {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
const styleBackImage = {
position: 'absolute'
}
const styleIconImage = {
width: 43,
height: 59
}
return (
<View style={[sizeStyle, styleImage]}>
<View style={[sizeStyle, styleBackImage]}>
<Image source={require('../assets/background.png')} />
</View>
<View >
<Image style={styleIconImage} source={require('../assets/icon.png')} />
</View>
</View>
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment