我知道如何以编程方式将 recyclerview 滚动到特定位置。但我的问题是我有一个带有垂直linearLayout 的recyclerview,它的每一行都有另一个子recyclerview gridlayout。现在,当我以编程方式滚动父 recyclerview 时,它不会滚动到给定位置。但是,如果从中删除子 recyclerview,那么它会毫无问题地滚动。这是我已经尝试过的,并且一切都适用于在其行中没有子 recyclerview 的单个 recyclerview。
card_recyclerView.getLayoutManager().scrollToPosition(position)
card_recyclerView.smoothScrollToPosition(position);
card_recyclerView.getLayoutManager().scrollToPositionWithOffset(position, 20);
我的主要回收站视图
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/card_recyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:clipToPadding="false"
android:layout_marginLeft="5dp"
android:background="#ffffff"
android:layout_weight="1"
/>
主要 recyclerview 行项目
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cards_recycler_adapter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/layout_see_more_top"/>