1

我有一个包含核心组件 SectionList 的 React Native 页面。SectionList 具有粘性节标题 (stickySectionHeadersEnabled) 和列表页脚 (ListFooterComponent)。当用户滚动过去最后一节时,最后一节页眉仍然停留在页面顶部,覆盖页脚。但是,我希望将粘性标题包含在部分列表区域的正文中,而不是在最后一部分结束后保留​​在屏幕上。

是否可以使用 SectionList 来实现这一点,还是应该采取另一种方法?

展示这种行为的 Expo 小吃(仅限 iOS 和 Android)

https://snack.expo.io/@unstableair/rn-sectionlist-footer-overlay-example

    <SectionList
      sections={DATA}
      keyExtractor={(item, index) => item + index}
      renderItem={({ item }) => (<View style={styles.item}><Text style={styles.title}>{item}</Text></View>)}
      renderSectionHeader={({ section: { title } }) => (<Text style={styles.header}>{title}</Text>)}
      stickySectionHeadersEnabled={true}
      ListFooterComponent={<View style={styles.footer}><Text>ListFooterComponent </Text></View>}
    />
4

1 回答 1

1

为了解决这个问题,我在 SectionList 数据的底部添加了一个空白部分。最后一个 SectionHeader 仍然覆盖 ListFooter 但因为它是一个高度为 0 的视图,所以您看不到它。

于 2020-04-18T13:43:59.457 回答