React native 嵌套的ScrollView如何在React Native中扩展到100%的高度?
我有一个用户配置文件的主ScrollView,然后在该ScrollView中我调用一个组件,它也是一个具有相同垂直方向的ScrollView 我希望展开嵌套组件,使其高度为其中内容的100%。目前,屏幕的高度似乎接近屏幕的高度,而其中的内容似乎更长 我当前拥有的代码如下所示:React native 嵌套的ScrollView如何在React Native中扩展到100%的高度?,react-native,view,scrollview,React Native,View,Scrollview,我有一个用户配置文件的主ScrollView,然后在该ScrollView中我调用一个组件,它也是一个具有相同垂直方向的ScrollView 我希望展开嵌套组件,使其高度为其中内容的100%。目前,屏幕的高度似乎接近屏幕的高度,而其中的内容似乎更长 我当前拥有的代码如下所示: <ScrollView style={{ flex: 1 }} contentContainerStyle={{ marginTop: HEADER_MAX_HEIGHT, paddingBottom: HEADER
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ marginTop: HEADER_MAX_HEIGHT, paddingBottom: HEADER_MAX_HEIGHT * 1.5 }}>
...irrelevant code here
{showSub && <Sub uid={uid} /> }
</ScrollView>
…不相关的代码
{showSub&}
Sub的广义定义是这样的,我从这个例子中删除了一些不必要的代码:
<ScrollView style={{ flex: 1 }}
contentContainerStyle={{ marginTop: 0, paddingBottom: 0 }}
scrollEventThrottle={2}
onScroll={this.onScroll}
refreshControl={<RefreshControl refreshing={refreshing} onRefresh={this.onRefresh} />}
>
...irrelevant code here
<View>
{categories && Object.keys(categories).map((category, catIndex) => {
let currentCategory = categories[category]
let collections = currentCategory['data']
let categoryName = currentCategory['categoryName']
return (
<View key={category}>
<TouchableOpacity style={{ flex: 1 }} onPress={() => this.props.navigation.navigate('Category', { category })}>
<Text style={{ flex: 1, fontSize: 28, fontWeight: 'bold', marginTop: 15, marginLeft: generalPadding }}>
{categoryName}
</Text>
</TouchableOpacity>
</View>)}
</View>
</ScrollView>
…不相关的代码
{categories&&Object.keys(categories).map((category,catIndex)=>{
让currentCategory=类别[类别]
let collections=currentCategory['data']
让categoryName=currentCategory['categoryName']
返回(
this.props.navigation.navigate('Category',{Category})}>
{categoryName}
)}
我已经尝试了ScrollView的高度:“100%”,但没有达到所需的高度。Welp,我可以通过将内容包装在高度为100%的视图中来解决这个问题