Click not working on RecyclerView in CoordinatorLayout when scrolling

recyclerview item click not working
appbarlayout not working
recyclerview single click not working but works when click twice
appbarlayout behavior

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 :

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.

Handling Scrolls with CoordinatorLayout · codepath/android_guides , The floating action button has a default behavior that detects Snackbar views being When a CoordinatorLayout notices this attribute declared in the RecyclerView, it will Keep in mind that ScrollView does not work with CoordinatorLayout . If the LinearLayout holds something else then you should add some scroll flags to that too, probably best would be app:layout_scrollFlags="scroll|enterAlwaysCollapsed" if it is supposed to scroll off screen. Lastly, make sure you are not disabling nested scrolling in your RecyclerView.

If Using RecyclerView in NestedScrollView add this line to RecyclerView :


I hope it help you.

RecyclerView within NestedScrollView Scrolling Issue, As we already know that recyclerView has a smooth scrolling by itself but when we need to put recyclerView within any scrollView it will not work like the below  Espresso, scrolling not working when NestedScrollView or RecyclerView is in CoordinatorLayout. It looks like CoordinatorLayout breaks the behaviour of Espresso actions such as scrollTo() or RecyclerViewActions.scrollToPosition().

I also found this problem ... after wasting so many hours searching and trying different things, I came out with a trick, its not pretty but it could work for someone else too.

Basically the idea is simulate a click on the nestedScrollView. In my case after I detect the 'AppBarLayout' its fully expanded, I send a tap to the nested.

protected void onCreate(final Bundle savedInstanceState) {

    getAppBarLayout().addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {

      public void onOffsetChanged(final AppBarLayout appBarLayout, final int verticalOffset) {

          if (verticalOffset == 0) { 
              // State.EXPANDED
          } else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) { 
              // State.COLLAPSED
          } else { 
              // State.IDLE

private void simulatedClick(@NonNull final View view) {
    // Obtain MotionEvent object
    final long downTime = SystemClock.uptimeMillis();
    final long eventTime = SystemClock.uptimeMillis() + 100;
    final MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, 0.0f, 0.0f, 0);
    // Dispatch touch event to view

NOTE: I don't really recommend the use of hacks like this, it's unprofessional and unmaintainable, but the more you know...

An sticky button with CoordinatorLayout Behaviors, It worked fine when scrolling but not when flinging. For some reason, when the user flings and you change the LayoutParams of the button, the buttons is not  When i try to scroll, sometimes it doesn't work. reason for this is, other elements of layout with click events are consuming the touch event. Basically EditText, RadioButton, Button are consuming touch events.

Improve RecyclerView Performance - Noteworthy, As I said my first problem was about RecyclerView's smooth scroll. every item has a photo slider, some texts, a rating bar, a favorite image button, and a button. Now when I click on any item I don't see the on click listener working. Here is my code for the Adapter class: public class FeaturedProductsAdapter extends RecyclerView.Adapter<FeaturedProductsAdapter.CustomViewHolder> { private List<FeaturedProductInfo> feedItemList; private Context mContext;

Collapsing Toolbars, toolbar, CollapsingToolbarLayout integrates with AppBarLayout , CoordinatorLayout , Toolbar , and a scrollable content view, such as RecyclerView . I have RecyclerView with NestedScrollView and Toolbar. I want to place adview banner in the bottom so when a user is scrolling the banner is always visible. I don't know how to separate these views

Design Support Library (IV): Collapsing Toolbar Layout, We saw that Coordinator Layout is the central point the other components rely on to work properly, and that AppBarLayout helps the toolbar and other components to react to scroll Anchor the Floating Action Button I used this collapsing toolbar layout with Recycler View as a child of CoordinatorLayout, the problem I was  Unfortunately simply switching to one of these views is not a possibility for me so I am still looking for a solution. Answer: I believe you need to make your ListView implement both ScrollingView and NestedScrollingChild interfaces. It's not the easiest thing, but you should be able to do it if you look at RecyclerView's source code.

  • Its really helpful