[英]ReactNative Screen Background and header icon
I have background image like below我有如下背景图片
On top of the screen background image, I have to place icon at the center like below,在屏幕背景图像的顶部,我必须将图标放在中心,如下所示,
Full screen or horizontal mode全屏或水平模式
How can I place circle icon in the background image without clipping image in full screen.如何在不全屏剪切图像的情况下将圆形图标放置在背景图像中。 Because in full screen the curve shaped image is not visible and icon appear in the middle of screen.
因为在全屏中,曲线形状的图像不可见,并且图标出现在屏幕中间。
<SafeAreaView style={styles.container}>
<ImageBackground
style={{flex: 1}}
source={require('../../assets/images/test.png')}
>
<View style={styles.container}>
<Image
source={require('../../assets/icons/app_icon.png')}
style={{
width: 200,
height: 200,
marginTop: 100
}}
/>
<View style={styles.contentCenter}>
<Text style={styles.textStyle}>
The Big Bang Theory
</Text>
</View>
</View>
</ImageBackground>
const styles = StyleSheet.create({
container: {
flex: 1,
},
title: {
fontSize: 25,
padding: 15,
color: 'white',
fontWeight: 'bold',
textAlign: 'center',
},
contentCenter: {
justifyContent: 'center',
alignItems: 'center',
},
textStyle: {
color: 'white',
padding: 10,
}
}
There are multiple things here that can affect this这里有很多事情会影响这一点
First of all, you haven't provided resizeMode
to your ImageBackground
that's probably why your curve is not showing up in full screen.首先,您没有为
ImageBackground
提供resizeMode
,这可能是您的曲线没有全屏显示的原因。
Second, You can use position: 'absolute'
and then top
, bottom
, left
, right
property to position your image on top of ImageBackground
.其次,您可以使用
position: 'absolute'
然后使用top
、 bottom
、 left
、 right
属性将图像定位在ImageBackground
的顶部。 zIndex
can also affect your View here zIndex
也会影响你的 View here
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.