蓝黑白底是ImageBackground
a,中间的绿条是a View
。代码是:
<ImageBackground
source={require('@images/login-background.jpg')}
style={{
flex: 1,
width: '100%',
resizeMode: 'cover',
justifyContent: 'center',
}}
>
<View style={{
width: '100%',
backgroundColor: 'green',
borderRadius: 15,
padding: 15
}}/>
</ImageBackground>
我希望15px
在 green 的左右边缘有填充View
。如果是ImageBackground
,View
我会在其中添加15px
填充,但是当它是时ImageBackground
,会导致:
相反,如果我添加margin: 15px
到 green View
,我会得到:
我应该如何处理这个,让它看起来像这样?