簡體   English   中英

無需滾動即可反應原生水平列表視圖。 如何包裝物品?

[英]react native horizontal list view with no scroll. How to wrap item?

我正在顯示列表中的項目。 我不想使用水平滾動視圖,但如何包裝項目以使它們不會掉出屏幕? 就像我們在android中有FlowLayout一樣。 圖為第一行第三項在屏幕外的一半

<List  horizontal={true} 
                            scrollEnabled={false}
                            style={{flexWrap: "wrap"}}
                            dataArray={articleData.Types}
                              renderRow={(Type) =>
                                <ListItem style={{borderBottomWidth: 0}} content>
                                    <Button rounded>
                                    <Text>{Type.Name}</Text>
                                    </Button>
                                </ListItem>
                            }>
                            </List>

可以使用視圖來實現這一點:

<View style={styles.wrapContainer}>
    {DATA.map(data => {
      return (
        <View style={styles.buttonContainer} >
          <Button title={data.name}/>
        </View>
      )})
    }
  </View>

工作示例

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM