ReactNative:SectionList SectionHeaders覆盖ListFooter

时间:2020-04-16 10:50:19

标签: react-native react-native-sectionlist

我有一个React Native页面,其中包含核心组件SectionList。 SectionList具有粘性节标题(stickySectionHeadersEnabled)和列表页脚(ListFooterComponent)。当用户滚动到最后一个部分时,最后一个部分的页眉仍停留在页面顶部,从而覆盖页脚。但是,我希望粘性标头包含在节列表区域的主体中,而不要保留在最后一节末尾的屏幕上。

是否可以通过SectionList实现此目标,或者我应该采用另一种方法?

展示这种行为的博览会小吃(仅限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>}
    />

1 个答案:

答案 0 :(得分:0)

要变通解决此问题,我在SectionList数据的底部添加了一个空白部分。最后一个SectionHeader仍会覆盖ListFooter,但由于它是高度为0的View,因此您看不到它。

相关问题