reactjs - 为什么我的 ImageBackground 视图不会延伸到 React Native 中的屏幕底部?
问题描述
我的 ImageBackground 只会扩展到它的内部内容,即使它的父级一直到达屏幕底部。如何让我的 ImageBackground 视图完全扩展到其父视图的底部?
<View style={styles.container}>
<View>
<Text style={styles.closeContainer} onPress={() => this.closeSideBar()}>
<MBIcon name='ico-24-chevron-left' style={styles.closeIcon} />
CLOSE
</Text>
</View>
<ScrollView style={styles.contentContainer}>
<View style={styles.userContainer}>
<Text style={styles.userName}>{username}</Text>
</View>
<ImageBackground source={require('../../assets/drawer-bg.png')} style={styles.imageBackgroundView} imageStyle={styles.imageBackground}>
<TouchableOpacity onPress={() => Actions.home()}>
<View>
<Text style={styles.links}>Home</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => this.performNetworkAction(Actions.orders, {orderStatus: 'notDelivered'})}>
<View>
<Text style={styles.links}>Scheduled Deliveries</Text>
</View>
</TouchableOpacity>
</ImageBackground>
</ScrollView>
</View>
CSS:
container: {
backgroundColor: '#262626',
height:'100%',
width:'100%',
display: 'flex'
},
contentContainer: {
height: '100%',
flex: 3,
backgroundColor: '#262626',
position: 'relative',
borderColor: 'green',
borderStyle: 'solid',
borderWidth: 2
},
imageBackgroundView: {
width: '100%',
borderColor: 'yellow',
borderStyle: 'solid',
borderWidth: 2,
position: 'relative',
flex: 1
},
imageBackground: {
height: '100%'
},
我已经概述了我的 ImageBackground 视图及其父容器:
解决方案
在滚动视图中“样式”不起作用,而是使用“contentContainerStyle”所以这段代码
<ScrollView style={styles.contentContainer}>
会变成
<ScrollView contentContainerStyle={styles.contentContainer}>
并在 imageBackgroundView 中添加 height='100%'
推荐阅读
- r - 根据时间对数据框进行条件添加或行
- data-structures - python3 - 删除一个节点
- wordpress - Woocommerce B2B 插件是否需要?
- postgresql - 如何在 liquibase 中设置当月第一个日期和下个月的默认值?
- pdf - 无法单击 PDF 中的签名字段,但在 Adobe Acrobat Reader 上打开并保存后可以使用
- onedrive - Microsoft Graph SDK OneDrive uploadSession 错误代码:BadRequest
- python - ElementTree 写入方法意外返回 TypeError
- visual-studio - 下载 Clickonce 时如何排除特定文件?
- git - 使用 Jenkins 管道的 Git 结帐非常慢
- node.js - 如何生成一个链接,用户可以点击进入 NodeJS 后端的电子邮件?