react-native - 将粘性标题添加到滚动视图
问题描述
有没有办法将标题添加到垂直滚动时粘滞但水平滚动时定期滚动的滚动视图。
<ScrollView
directionalLockEnabled = {false} horizontal = {true} maximumZoomScale = {1} scrollEnabled = {true} minimumZoomScale = {.45} zoomScale = {1}
onScroll = {this.handleScroll}
scrollEventThrottle = {100}
stickyHeaderIndicies = {[0]}
>
<FlatList
contentContainerStyle = {{flexGrow: 1}}
style = {{height: 2000}}
data = {this.state.data}
ItemSpeparatorComponent = {this.renderSeparator}
keyExtractor = {(x, i) => i.toString()}
onEndReached = {this.loadMoreData}
onEndReachedThreshold = {0.1}
renderItem ={({item}) =>
<View style = {{flex: 1, flexDirection: 'row'}}>
<View style = {{width:100, height: 100}}>
<Text style= {styles.itemText}>
{item.inletThread}
</Text>
</View>
<View style = {{width:115, height: 100}}>
<Text style= {styles.itemText}>
{item.manufacturer}
</Text>
</View>
<View style = {{width:165, height:100}}>
<Text style= {styles.itemText}>
{item.testPressure}
</Text>
</View>
<View style = {{width:182, height: 100}}>
<Text style= {styles.itemText}>
{item.workingPressure}
</Text>
</View>
<View style = {{width:80, height: 100}}>
<TouchableOpacity onPress={ this.SampleFunction.bind(this, item)}>
<Text style = {{textAlign: 'center', paddingTop: 25, fontWeight: 'bold', fontSize: 25}}>Click here</Text>
</TouchableOpacity>
</View>
</View>
}
ItemSeparatorComponent = {this.renderSeparator}
ListHeaderComponent = {this.renderHeader}
stickyHeaderIndicies = {[0]}
/>
</ScrollView>
这会使标题很好,但在任一方向滚动时它不会粘在屏幕顶部。我已经通过将标题放在滚动视图中并同步两个滚动视图 x 组件来使其工作,但是由于状态调用,此方法非常慢。
如果有人有另一种方法,我可以尝试一下,那就太好了。
解决方案
也许这为时已晚,但对于其他在这里搜索这个问题的人来说,这是我资助的一个 github 项目(它不是我的):GitHub 链接
推荐阅读
- ansible - 使用 Ansible 将数据从 Google Compute Engine 发送到 Google Pub/Sub
- html - 幻灯片图像不显示为幻灯片,而是显示在彼此下方
- javascript - Javascript - 我无法访问列表的内容
- node.js - Puppeteer:设置屏幕截图输出尺寸
- javascript - MongoTimeoutError: Server selection timed out after 30000 ms, 使用heroku部署
- https - 如何为 VS Code Live Server 扩展启用 HTTPS?
- php - 循环(行)查询中的另一个 SQL 查询
- java - 访问 Scala 变量:“未找到值:variable_name”问题
- javascript - Discord bot 改为返回空字符串
- r - 在 R 中按空格分割字符串