onTouch()方法未收到ACTION_DOWN

时间:2018-10-17 14:16:17

标签: android android-recyclerview android-constraintlayout swiperefreshlayout android-nestedscrollview

我有一个应用,需要在RecyclerViewConstraintLayoutNestedScrollView内显示多个SwipeRefreshLayout

所有RecyclerView的{​​{1}}都水平放置。

因此,我当前的布局树如下所示:

LinearLayoutManager

我要实现的目标类似于主屏幕上的Google Play应用。

我的问题是,<SwipeRefreshLayout> <NestedScrollView> <ConstraintLayout> <RecyclerView></RecyclerView> <RecyclerView></RecyclerView> <RecyclerView></RecyclerView> ... </ConstraintLayout> </NestedScrollView> </SwipeRefreshLayout> 对于被认为是水平滑动的方式过于挑剔。

我尝试RecyclerView,但无济于事。

然后我开始研究setNestedScrollingEnabled(false)以上所有内容的onTouch()方法,发现RecyclerView中的ACTION_DOWN仅在我滚动非常慢时才会出现-任何,则可以认为滑动/翻转不会产生MotionEvent,而只会产生ACTION_DOWNACTION_MOVE

关于此结构我是否不了解?某些视图会消耗ACTION_UP吗?

还有一个副问题-是否有示例不仅可以重新创建Google Play主屏幕的外观,还可以重新创建一种感觉?当涉及到水平滚动时,他们的水平列表更加宽容。

编辑:将ACTION_DOWN添加到了我所有的OnItemTouchListener中。它会正确拦截所有挥动/滑动/滚动,但不是全部都会触发OnSwipeListener。这是代码。旁注:OnSwipeListener来自this answer,并略微增加了RecyclerView方法

onScroll

0 个答案:

没有答案
相关问题