【发布时间】:2020-12-14 09:41:29
【问题描述】:
由于某种原因,在 ScrollView 上调用 scrollTo({x: 50}) 和在 FlatList 上调用 scrollToOffset({offset: 50}) 仅在 Android 上没有动画。
const scrollViewRef = useRef<ScrollView>(null);
...
const handleOnPress = useCallback(
(data) => {
scrollViewRef.current.scrollToOffset({offset: getOffset(data)});
...
},
[getOffset]
);
...
<ScrollView
ref={scrollViewRef}
...
>
<MyItem onPress={handleOnPress}/>
<ScrollView/>
在使用 FlatList 并进行适当调整时会出现同样的问题。
【问题讨论】:
-
默认情况下 animated 为 true 但请尝试手动设置。
-
谢谢@LeriGogsadze,我确实试过了。请参阅我的答案以了解我的问题。
-
你能给我一个小吃网址吗?
标签: android react-native react-native-android react-native-flatlist react-native-scrollview