Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native ScrollView is cut off from the bottom on iOS

I've just encountered a weird issue that I didn't know why it was happening. For some reason, I can't scroll to the bottom of my <ScrollView>.

Here's my code: https://repl.it/Iqcx/0

Thanks!

like image 596
Emad Salah Avatar asked Jun 18 '17 14:06

Emad Salah


2 Answers

In my case the issue wasn't flex: 1 or flexGrow: 1, but using padding on ScrollView styles.

So instead of doing this:

<ScrollView style={{padding: 40}}>
  {/* MY CONTENT HERE */}
</ScrollView>

I did this:

<ScrollView>
  <View style={{padding: 40}}>
    {/* MY CONTENT HERE */}
  </View>
</ScrollView>

And the problem was fixed.

So if you want to add padding to your ScrollView, create a View inside it and apply padding to it instead.

like image 182
Claudio Holanda Avatar answered Oct 16 '22 12:10

Claudio Holanda


flex:1 to the outer parent

<View> //Parent
 <Header/>
 <ScrollView/>
</View>

if ScrollView is cutting off, assign parent <View> flex:1

<View style={{flex:1}}> //Parent
 <Header/>
 <ScrollView/>
</View>
like image 45
Dhaval Jardosh Avatar answered Oct 16 '22 13:10

Dhaval Jardosh