滚动时,单击在CoordinatorLayout中的RecyclerView上不起作用 [英] Click not working on RecyclerView in CoordinatorLayout when scrolling

本文介绍了滚动时,单击在CoordinatorLayout中的RecyclerView上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AppBarLayout之后,RecyclerView作为CoordinatorLayout的第二个子对象,我正面临一个奇怪的行为(如许多示例中所述).

I am facing a strange behaviour with a RecyclerView as a second child of CoordinatorLayout, just after an AppBarLayout (as described in a lot of examples).

我的问题是,当我滚动回收器视图时,我想单击特定的项目.有时我需要单击2次以选择该项目,它似乎与逃避行为有关.例如,如果我滚动到回收者"视图的底部,那么如果我将手指从屏幕底部移到顶部(以查看更多数据,但是在我的情况下,由于我无法看到更多数据,已经到了底部),然后快速单击一个项目,似乎停止了投放,第二次单击实际上选择了该项目... 使用没有CoordinatorLayout的简单回收器视图时,显然不会发生这种情况.

My problem is when I scroll the recycler view and I want to click on a particular item. Sometimes I need to click 2 times to select that item, it seems to be linked to the fling behaviour. For example, if I scrolled to the bottom of the recycler view, then if I fling my finger from the bottom of the screen to the top (in order to see more data, but in my case I can't see more data since I am already to the bottom) and then quickly click on an item, it seems to stop the fling, and the second click actually select the item... This behaviour is clearly not happening when using a simple recycler view without CoordinatorLayout.

我的recyclerview仅保存一个简单的String列表,并使用以下布局行为:@ string/appbar_scrolling_view_behavior

My recyclerview is just holding a simple list of String, and using the following layout behaviour : @string/appbar_scrolling_view_behavior

你知道为什么吗?

我刚刚尝试了Android Studio示例滚动活动",它看起来像是Google支持存储库中的错误. 实际上,当使用支持版本26.1.O(与26.0.0和26.0.2相同)时,存在我正在谈论的错误,但是如果尝试使用版本26.0.0-alpha1或26.0.0-beta1,它实际上正在工作...

I just tried with the Android Studio sample Scrolling Activity, and it looks like it is a bug from Google support repository. In fact, when using support version 26.1.O (same with 26.0.0 and 26.0.2), the bug I am talking about is present, but if you try with the version 26.0.0-alpha1 or 26.0.0-beta1, it is actually working...

Google有两个有关此问题的公开错误: https://issuetracker.google.com/u/1/issues/66996774 https://issuetracker.google.com/u/1/issues/68077101

There is two open bugs at Google about this : https://issuetracker.google.com/u/1/issues/66996774 https://issuetracker.google.com/u/1/issues/68077101

如果您遇到相同的问题,请给这些错误加注星标

Please star these bugs if you are facing the same problem

推荐答案

Google刚刚针对此错误发布了一种解决方法,它将在以后公开发布.

Google just posted a workaround for this bug, it will be publicly released later.

https://gist.github.com/chrisbanes/8391b5adb9ee42180893300850ed02f2

这篇关于滚动时,单击在CoordinatorLayout中的RecyclerView上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆