Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click not working on RecyclerView in CoordinatorLayout when scrolling

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

like image 280
gxela Avatar asked Oct 21 '17 11:10

gxela


Video Answer


1 Answers

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

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

like image 196
gxela Avatar answered Oct 02 '22 02:10

gxela