我正在处理Android TV相关的工作。在我们的Fragment中,有两个水平RecyclerView。当我使用右方向键滚动第一个RecyclerView时,它可以很好地滚动。但是当我到达其RecyclerView的最后一个焦点项时,焦点会自动转移到第二个RecyclerView的项上。
如何防止这种情况发生?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/firstRelativeGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/gridView1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:clipToPadding="false"
android:focusable="false"
android:paddingLeft="0dp"
android:paddingRight="755dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/gridView2"
android:layout_width="155dp"
android:layout_height="200dp"
android:layout_alignBaseline="@+id/gridView1"
android:layout_marginLeft="0dp"
android:focusable="false"
android:nextFocusRight="@null"
android:nextFocusUp="@+id/home_textview" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/secondRelativeGrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="vertical">
<android.support.v17.leanback.widget.MyHorizontalGridView
android:id="@+id/gridView3"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:clipToPadding="false"
android:focusable="false"
android:paddingLeft="0dp"
android:paddingRight="754dp" />
<android.support.v17.leanback.widget.MyHorizontalGridView
android:id="@+id/gridView4"
android:layout_width="155dp"
android:layout_height="200dp"
android:layout_alignBaseline="@+id/gridView3"
android:layout_marginLeft="0dp"
android:clipToPadding="false"
android:descendantFocusability="blocksDescendants"
android:focusable="false"
android:paddingLeft="0dp"
android:paddingRight="-2dp"
/>
</RelativeLayout>