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

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

问题描述

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

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

我的回收视图只是持有一个简单的字符串列表,并使用以下布局行为:@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,它实际上正在工作...

谷歌有两个关于此的公开错误:https://issuetracker.google.com/u/1/issues/66996774https://issuetracker.google.com/u/1/issues/68077101

如果您遇到同样的问题,请为这些错误加星

解决方案

Google 刚刚发布了此错误的解决方法,稍后将公开发布.

https://gist.github.com/chrisbanes/8391b5adb9ee42180893302e42180893300850ed02f2"

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).

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.

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

Do you have any idea why ?

[EDIT] 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...

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 just posted a workaround for this bug, it will be publicly released later.

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

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

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