1

I have an issue where if the RecyclerView has a lot of items (more than 180), the user automatically scrolls down to the bottom of the list when I click D-PAD Down on the first row. I am using a GridLayout for this list.

This is my Custom Recycler View's onDispatchEvent():

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
   return super.dispatchKeyEvent(event);
}

Here is the view:

<layout xmlns:android="http://schemas.android.com/apk/res/android">

    <RelativeLayout
        android:id="@+id/entry_container"
        android:descendantFocusability="beforeDescendants"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <CustomRecycleView
            android:id="@+id/list_view_horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/row_title"
            android:layout_marginLeft="@dimen/margin_filter"
            android:layout_marginRight="@dimen/margin_filter" />
   </RelativeLayout>
</layout>

This issue does not appear when loading around 120-130 items. Has anyone encountered this type of automatic scrolling before?

blackpanther
  • 10,998
  • 11
  • 48
  • 78

1 Answers1

0
recyclerView.scrollToPosition(List.size - 1)

In my case, the above code work for me. It will automatically scrolled the screen to the last item added in the list.

Zeeshan Ayaz
  • 858
  • 6
  • 11