reactjs - 为什么我的 ImageBackground 不再延伸到屏幕底部?
问题描述
我已将 ImageBackground 包装在 ScrollView 中,但现在我的内容不再延伸到底部。仅供参考,ScrollView 一直到底部,但 Imagebackground 没有。如果没有 ScrollView,内容会一直到底部,而其下方没有任何空间。有谁知道为什么我的 ScrollView 阻止我的 ImageBackground 到达屏幕底部?我省略了与外部内容无关的样式。
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {View, StyleSheet, Text, ImageBackground, TouchableOpacity, Image, ActivityIndicator, ScrollView} from 'react-native';
import Header from '../../components/Header/Header';
import Loader from "../../components/Login/Loader";
import {loadCustomerOrderDetails} from '../../actions/AppActions'
import {connect} from "react-redux";
import {Actions} from 'react-native-router-flux';
import {createIconSetFromIcoMoon} from 'react-native-vector-icons';
import selection from '../../selection';
const MBIcon = createIconSetFromIcoMoon(selection);
class Home extends Component {
constructor(props) {
super(props);
this.props.dispatch(loadCustomerOrderDetails(this.props.customerId));
}
render() {
const {isLoading, details} = this.props.customerData;
const {invoices, unsubmittedOrders, itemIssues, deliveryStats} = details;
let customerName = 'Select Account...';
if (unsubmittedOrders && unsubmittedOrders.customerName) {
customerName = unsubmittedOrders.customerName;
}
return (
<View style={styles.wrapper}>
<Header style={styles.header}/>
<ScrollView style={{ flex: 1 }}>
<ImageBackground source={require('../../assets/loginBG.jpg')} style={styles.backgroundImage}>
<View>
<Image style={styles.mblogo} source={require('../../assets/mb_logo.png')} />
</View>
{isLoading &&
<ActivityIndicator
style={{alignSelf: 'center'}}
animating={true}
size='large'
/>
}
</ImageBackground>
</ScrollView>
</View>
);
}
}
Home.propTypes = {
customerData: PropTypes.object,
customerId: PropTypes.string,
}
function mapStateToProps(state) {
const {customerData, app} = state;
return {
customerData: customerData,
customerId: app.customerId
};
}
export default connect(mapStateToProps)(Home);
var styles = StyleSheet.create({
wrapper: {
flex: 1,
backgroundColor: 'transparent',
position: 'relative'
},
header: {
height: 200,
width: '100%',
position: 'absolute',
top: 0,
left: 0,
right: 0
},
backgroundImage: {
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'center',
backgroundColor:'rgba(0,0,0,0.45)',
width: null,
height: '100%',
marginTop: 55,
flex: 1,
position: 'relative',
bottom: 0
},
content: {
flex: 1,
justifyContent: 'space-between',
},
homeSection: {
flex: 2,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'center',
width: '90%',
margin: 'auto',
},
cartBtnContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
marginVertical: 8
},
footerBtn: {
width: '45%',
height: 48,
justifyContent: 'center',
alignItems: 'center',
borderRadius: 24,
}
});
解决方案
放入:ScrollView
_ImageBackground
<ImageBackground>
<ScrollView>
......
</ScrollView>
</ImageBackground>
推荐阅读
- python - 在导入中包含包层次结构
- mule - 从 Mule Dataweave 过滤 Json 数组
- python - “ImageField”字段中的默认图像 - Django
- azure - 对如何在 Blazor App 中从 B2C 获取访问令牌感到困惑
- spring - 每当 Spring Integration Poller 触发时写入日志
- asp.net - 部署到本地 IIS 服务器时找不到 /signalr/hubs 404,适用于 IIS express + signalr 1.0
- recursion - 如何在序言中返回一个数字?
- python - python检查字典值是否由字符串列表组成
- python - 如何修复变换透视功能错误地以错误的方向返回图像
- javascript - 引用具有未定义值的变量