Android Multiple RecyclerView последняя позиция не сохраняется - PullRequest
0 голосов
/ 22 октября 2019

Я использую 2 RecyclerViews с различными размерами изображений в Recycler Item, и прикрепленное изображение дает больше представления об интерфейсе пользователя. Я разрабатываю это приложение для Android TV. Проблема, с которой я здесь сталкиваюсь, заключается в том, что, пока я перемещаю фокус с одного recylerView на другой и возвращаюсь к предыдущему представлению переработчика, фокус не приходит к последнему выбранному элементу. Фокус смещается к ближайшему элементу в следующем окне recyclerView.

Поэтому мой вопрос заключается в том, как управлять этим поведением фокуса и последним состоянием recyclerView здесь.

MyHomeFragment.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:focusableInTouchMode="true"
      android:orientation="vertical">

      <TextView
          android:id="@+id/tv1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          />

      <androidx.recyclerview.widget.RecyclerView
          android:id="@+id/rv1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clipChildren="true"
          android:clipToPadding="true" />

      <TextView
          android:id="@+id/tv2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          />

      <androidx.recyclerview.widget.RecyclerView
          android:id="@+id/rv2"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clipChildren="true"
          android:clipToPadding="true" />

  </LinearLayout>
</androidx.core.widget.NestedScrollView>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...