如何使ListHeaderComponent在SectionList中成为粘性头部? [英] how can we make ListHeaderComponent as sticky header in SectionList?
本文介绍了如何使ListHeaderComponent在SectionList中成为粘性头部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
说明
我在ListHeaderComponent
中使用水平选项卡栏,我想将ListHeaderComponent
作为SectionList中的粘性标题。我们可以通过stickyHeaderIndices={[0]}
在扁平列表中制作粘滞标题,但在SectionList
Reaction本机版本:
React Native Environment Info:
System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Memory: 38.35 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.15.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.1, 29.0.2
System Images: android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.59.8 => 0.59.8
npmGlobalPackages:
rename-horizon: 1.1.0
react-native-cli: 2.0.1
复制步骤
提供重现该问题的步骤的详细列表。
- 制作节目单并添加
ListHeaderComponent
道具 - 在部分列表中添加
stickyHeaderIndices={[0]}
它不会使ListHeaderComponent
成为粘性标题
预期结果
它应该使ListHeaderComponent
成为粘性标题。或其他方法使其成为粘性标题
推荐答案
使用类似的内容。
<View style={{ flex: 1 }}>
{renderStickyListHeaderComponent()}
<SectionList
{...sectionListprops}
ref={sectionListRef}
sections={sectionData}
stickySectionHeadersEnabled={false}
/>
</View>
这篇关于如何使ListHeaderComponent在SectionList中成为粘性头部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文