React native 如何在react native中将scrollview扩展到整个屏幕?

React native 如何在react native中将scrollview扩展到整个屏幕?,react-native,React Native,我有这个密码 render() { return ( <View style={styles.container}> <TopMenu /> <ScrollView style={styles.scrollView}> {array_with_two_items.map(this.createRow)} </ScrollView> </View> ) } 问题

我有这个密码

render() {
  return (
    <View style={styles.container}>
      <TopMenu />
      <ScrollView style={styles.scrollView}>
        {array_with_two_items.map(this.createRow)}
      </ScrollView>
    </View>
  )
}
问题是它看起来像这样

+-----------+
|    MENU   |
+-----------+
|   item1   |
+-----------+
|   item2   |
+-----------+
|           |
|   blank   |
|    not    |
| scrollable|
+-----------+
但我想让它看起来像

+-----------+
|    MENU   |
+-----------+
|   item1   |
+-----------+
|   item2   |
+-----------+
| blank,but |
|   still   |
|  part of  |
| scrollview|
+-----------+

我在造型和flexbox方面没有什么经验,所以这就是我为什么要问的原因。(菜单不应该是scrollview的一部分)

只需为scrollview提供道具contentContainerStyle,如:

<ScrollView
   contentContainerStyle={{
     flex: 1
  }}
>
  /* Other Stuff */
</ScrollView>


/*其他东西*/

我想你想要的是
flexGrow
-



尝试使用并添加contentContainerStyle={styles.contentContainer}(这是一个本机属性)来覆盖scrollView,您能给出一个小的用户案例代码片段吗@这很直截了当。使用contentContainerStyle将滚动视图定位为常规视图。不要使用样式来定位。Ajay的回答不言自明。设置flex:1将允许ScrollView占用屏幕本身(用作父容器)的剩余可用空间,或者您的ScrollView嵌套在其中的父容器。非常感谢您的帮助,这节省了我几天的痛苦和折磨这应该是可以接受的答案,因为只有flex:1停止ScrollView的滚动
<ScrollView
   contentContainerStyle={{
     flex: 1
  }}
>
  /* Other Stuff */
</ScrollView>

<ScrollView style={{ flex: 1 }} contentContainerStyle={{ flexGrow: 1 }}>

</ScrollView>