【发布时间】:2018-08-27 22:34:27
【问题描述】:
我正在开发 android 电视,在我们的 Fragment 中有两个 Horizontal Recyclerview,当我使用 D-pad 朝右方向滚动 First Recyclerview 时,它滚动良好,当我到达其 Recycler 视图的最后一个焦点项目时,会自动聚焦转到第二个 Recycler 视图项。
如何预防?
<?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>
【问题讨论】: