Click not working on RecyclerView in CoordinatorLayout when scrolling Click not working on RecyclerView in CoordinatorLayout when scrolling android android

Click not working on RecyclerView in CoordinatorLayout when scrolling


If Using RecyclerView in NestedScrollView add this line to RecyclerView :

android:nestedScrollingEnabled="false"

I hope it help you.


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() {      @Override      public void onOffsetChanged(final AppBarLayout appBarLayout, final int verticalOffset) {          if (verticalOffset == 0) {               // State.EXPANDED              simulatedClick(nestedScroll)          } 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    view.dispatchTouchEvent(motionEvent);}

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