【发布时间】:2020-08-07 13:01:30
【问题描述】:
蓝黑白背景是ImageBackground,中间的绿条是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>
我希望在绿色View 的左右边缘有填充15px。如果 ImageBackground 是 View 我会添加 15px 填充到它,但是当它是 ImageBackground 时会导致:
相反,如果我将margin: 15px 添加到绿色View,我会得到:
我应该如何处理它,让它看起来像这样?
【问题讨论】:
标签: css reactjs react-native react-native-image imagebackground