React Native - Have view height set by content

Viewed 7385

I have a view and a scroll view that currently take up the full height due to the flex: 1 property. I'm trying to figure out how the have this view only take up the amount of space that the content within the scroll view takes up. Is this possible?

<View style={{ flex: 1 }}>      
  <ScrollView style={{ flexDirection: 'row', flex: 1 }}>...</ScrollView>
</View>
4 Answers

Setting style={{ height: 'auto', flex: 0 }} on both View and ScrollView worked.

Add this to te Text component:

flexShrink: 1

Also you may need

flexWrap: "wrap"

Add height: "auto", alignSelf: 'flex-start'

Remove flex 1 from View, then if you set the height of ScrollView to 500 the View will be 500 as well.

Related