Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make ScrollView horizontal in react native

Tags:

react-native

I am using ScrollView for scrolling the list how can i make it horizontal it is appearing vertical

I also tried wrapping up in different views but its not working

for eg:

<View>  <ScrollView>  .  .  .  </ScrollView>  <View>
like image 651
dimpuW Avatar asked Aug 09 '17 12:08

dimpuW


People also ask

How use ScrollView horizontal in React Native?

In the ScrollView, we can scroll the components in both direction vertically and horizontally. By default, the ScrollView container scrolls its components and views in vertical. To scroll its components in horizontal, it uses the props horizontal: true (default, horizontal: false).

How do I create a horizontal scroll bar in React Native?

React native ScrollView component comes with a property to make one ScrollView horizontal. This prop is horizontal By default, it's value is false i.e. by default, we got one vertical ScrollView. We can convert it to a horizontal ScrollView by marking it false.


2 Answers

You need to define that you want to active horizontal in scrollview

<View>   <ScrollView   horizontal={true}   >   .   .   .   </ScrollView> <View> 

that may be help you

like image 142
ashutosh pandey Avatar answered Oct 04 '22 04:10

ashutosh pandey


Pass the horizontal={true} prop to the ScrollView Component.

By default, ScrollView is laid out vertically. In order to scroll the content horizontally, you simple need to pass a horizontal={true} prop to the ScrollView Component, like so:

<ScrollView horizontal={true}>    <Text>Child 1</Text>   <Text>Child 2</Text>   <Text>Child 3</Text>  </ScrollView> 

The above code will lay out Child 1, Child 2 and Child 3 horizontally instead of vertically.

You can read more on the official React Native docs.

like image 24
Joshua Pinter Avatar answered Oct 04 '22 03:10

Joshua Pinter