scrollToIndex在RTL FlatList React-Native中不起作用

时间:2019-11-19 08:03:31

标签: react-native react-native-android react-native-flatlist scrolltoindex

我有Horizo​​ntal FlatList,现在我将电话语言更改为阿拉伯语(RTL)。 scrollToIndex()在RTL中不起作用,没有RTL,它可以按预期工作。有什么建议吗?

FlatList

<FlatList
    style={myStyles.flatListStyle}
    horizontal={true}
    data={this.props.dataForFlatList}
    renderItem={this.renderItem}
    ref={(ref) => { this.flatListRef = ref; }}
    keyExtractor={item => item.id.toString()} />

Press()上的renderItem函数正在传递项目ID

this.flatListRef.scrollToIndex({ animated: true, index: id }); // Working fine without RTL - NOT WORKING WITH RTL

谢谢。

1 个答案:

答案 0 :(得分:0)

如果要滚动到渲染窗口之外,则需要指定getItemLayout道具