React Native FlatList separator between columns

前端 未结 6 1559
不思量自难忘°
不思量自难忘° 2021-02-18 20:57

I have a FlatList with multiple columns:

             


        
6条回答
  •  清歌不尽
    2021-02-18 21:33

    I watched your Expo. It is as below.

     1   2   3   4 
    ---------------
     5   6   7   8 
    

    I assume you want as below.

     1 | 2 | 3 | 4 
    ---+---+---+---
     5 | 6 | 7 | 8 
    

    To do this, It is not possible with ItemSeparatorComponent only. as Hazim Ali says, use different style per index.

    renderItem={({ item, index }) => (
            {item}
        )}
    

    This is the complete example.

    --

    But the separator only appear between rows, not between columns

    As far as I read the source code, when numColumns > 2, there is no itemseparator between columns. Itemseparator is only between row and row.

    Here is example. When numColumns is set 4, four items are grouped to one cell. And one itemSeparator is put between cells.

     1   2   3   4  <- cell1
    --------------- <- itemSeparator
     5   6   7   8  <- cell2
    

提交回复
热议问题