persona5
V2EX  ›  Android

ViewPager2 配合 Fragment(样式为一个 RecyclerView)使用,上下滑动时非常容易触发左右滑动,如何调节灵敏度?

  •  
  •   persona5 · May 5, 2020 · 15215 views
    This topic created in 2374 days ago, the information mentioned may be changed or developed.

    Fragment 中样式仅为一个 RecyclerView,界面在上下滑动时,非常容易触发 ViewPager2 的左右滑动。

    应该如何控制左右滑动不要那么“灵敏”?

    目前考虑的是如果解决不了,只能禁用掉手势滑动,通过 fakeDragBy() 方法来实现按钮左右切换页面。

    Android 新手,还望不吝赐教。

    3 replies  •  2020-05-06 09:23:55 +08:00
    fansangg
    fansangg
    May 5, 2020
    1
    建议上网搜一下 android 的 touch 事件传递机制,看看就会明白了
    fansangg
    fansangg
    May 5, 2020
    2
    move 的时候做判断是否拦截
    nicevar
    nicevar
    May 6, 2020
    3
    自己拦截触摸事件, 按情况进行过滤处理
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2791 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 14:10 · PVG 22:10 · LAX 06:10 · JFK 09:10
    ♥ Do have faith in what you're doing.