Zygro
Zygro

Reputation: 7119

ScrollView does not work when wrapped in View

I have a component kind of like this

<ScrollView>
  <Text>Hello World</Text>
  <Text>Hello World</Text>
  <Text>Hello World</Text>
  <Text>Hello World</Text>
   ...
</ScrollView>

and it works just fine. But if I wrap it in a view like this:

<View>
  <ScrollView>
    <Text>Hello World</Text>
    <Text>Hello World</Text>
    <Text>Hello World</Text>
    <Text>Hello World</Text>
     ...
  </ScrollView>
</View>

suddenly, it doesn't scroll. If I inspect one of the texts, it doesn't even show that it's wrapped in a scrollview. I have no idea what could cause this. Only tested on Android.

Upvotes: 0

Views: 71

Answers (1)

Henrik R
Henrik R

Reputation: 4982

The View component that is wrapping ScrollView has to have set height or flex: 1.

In short add flex: 1 or height: 50 // any number will do to View component

Upvotes: 1

Related Questions