1

我有一个问题,如果 RecyclerView 有很多项目(超过 180 个),当我单击第一行的 D-PAD Down 时,用户会自动向下滚动到列表底部。我为此列表使用了 GridLayout。

这是我的自定义回收站视图onDispatchEvent()

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

这是视图:

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

加载大约 120-130 个项目时不会出现此问题。有没有人遇到过这种类型的自动滚动?

4

1 回答 1

0
recyclerView.scrollToPosition(List.size - 1)

就我而言,上面的代码对我有用。它会自动将屏幕滚动到列表中添加的最后一项。

于 2019-05-08T18:44:53.630 回答