Scroll View inside view not working react native

Riten picture Riten · Jul 1, 2016 · Viewed 33.8k times · Source

Here I am trying a simple code but the scroll view is not working if kept inside another view. Code is like this:

  return(
  <View>
    <Toolbar title={this.props.title}>
    </Toolbar>

    <ScrollView>

      <HomeScreenTop />
      <HomeScreenBottom navigator={navigator}/>

      </ScrollView>

  </View>
 );

But if scroll view kept as parent view it works perfectly. Code is as below:

  return(
  <ScrollView>
    <Toolbar title={this.props.title}>
    </Toolbar>

      <HomeScreenTop />
      <HomeScreenBottom navigator={navigator}/>

  </ScrollView>
 );

Now the problem is I don't want my toolbar to scroll up and down, I just want the contents below the toolbar to move. How can I achieve that?

And next question: Is scroll view has to be parent view to be returned to work?

Answer

Led Machine picture Led Machine · Feb 16, 2018

Use the property flexGrow in the style, flex didnt worked for me.

 <ScrollView contentContainerStyle={{ flexGrow: 1 }}>
    ...
</ScrollView>