我有一个包含在 View 中的 FlatList
。
<View {...this._panResponder.panHandlers}>
<FlatList .../>
</View>
View 是一个 panResponder
,那么如何在 onPanResponderGrant
触发时禁用 FlatList 的滚动。
最佳答案
documentation说明 FlatList
具有 ScrollView
的属性:
and thus inherits it's props (as well as those of ScrollView)
如果您检查 documentation对于 ScrollView
,您会发现您需要做的就是将 scrollEnabled
属性设置为 false 以禁用滚动。您选择如何以及在何处执行此操作将取决于您,因为您并没有真正发布任何代码。处理此问题的一种简单方法是使用状态:
<FlatList
...
scrollEnabled={this.state.scrollEnabled}
/>
// Change the state to the appropriate value in onPanResponderGrant:
// To enable:
this.setState({ scrollEnabled: true })
// To disable:
this.setState({ scrollEnabled: false })
关于android - 如何在 FlatList 上启用或禁用滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45183968/