gpt4 book ai didi

android - ScrollView : How to reproduce snapToInterval and snapToAlignment for Android?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:01:41 28 4
gpt4 key购买 nike

我正在寻找一种以特定间隔滚动水平菜单的方法。

我有多个 child 在屏幕上可见

I have multiple children visible on screen

选中的状态在中心。

将 snapToInterval 与 snapToAlignement 结合使用完全满足了我的需求,但这些 Prop 仅适用于 iOS。

有办法实现吗?我想可以使用 PanResponder API,但我不知道如何实现它。

我使用的是 0.28 RN 版本。谢谢。

<ScrollView
decelerationRate={0}
horizontal
snapToAlignment="center"
snapToInterval={150}
>
{this.props.children}
</ScrollView>

最佳答案

有一个关于此问题的拉取请求:https://github.com/facebook/react-native/pull/15297

还有一个图书馆https://github.com/machadogj/react-native-carousel-control?files=1支持 Android 和 iOS 滑动,它本身控制滚动行为,但我试过了,它有效,但与 snapToInterval 相比没有那么流畅 |和 snapToAlignment .

这里是另一个更复杂的旋转木马滑动:https://github.com/archriss/react-native-snap-carousel

希望您能基于这些获得更多见解。

关于android - ScrollView : How to reproduce snapToInterval and snapToAlignment for Android?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38142552/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com