SDB_1998
SDB_1998

Reputation: 365

React-Native render a horizontal List that have 2 rows

I want to implement a List that have 2 rows and I can scroll horizontally and show more (two rows)

Just like this image: enter image description here

I have an array with these Items, but I can't figure out how to do that in flatlist since we render one item only at once. Also, is there any component if flatlist or scrollList can't be applied ?

Upvotes: 0

Views: 1814

Answers (1)

Muni Kumar Gundu
Muni Kumar Gundu

Reputation: 532

If you have only a single list and need to show 2 rows

<ScrollView
          horizontal
          showsVerticalScrollIndicator={false}
          showsHorizontalScrollIndicator={false}
          contentContainerStyle={{ paddingVertical: 20 }}>
          <FlatList
            scrollEnabled={false}
            contentContainerStyle={{
              alignSelf: 'flex-start',
            }}
            numColumns={Math.ceil(list.length / 2)}
            showsVerticalScrollIndicator={false}
            showsHorizontalScrollIndicator={false}
            data={list}
            renderItem={({ item, index }) => {
            //your image code 
        }}
          />
</ScrollView>

Snack URL

Upvotes: 2

Related Questions