在RecyclerView项中更改视图之间的焦点 (Android)

3

我正在适配我的应用程序以适用于Android TV。

我有一个包含项目的RecyclerView。每个项目包括三个LinearLayouts。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/LLChannel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:tools="http://schemas.android.com/tools"
    android:background="@drawable/item_touch_selector"
    android:paddingLeft="@dimen/list_item_extra_padding"
    android:paddingRight="@dimen/list_item_extra_padding"
    android:weightSum="1"
    android:orientation="horizontal"
    android:baselineAligned="false">


    <LinearLayout
        android:id="@+id/item_content"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:layout_weight="0.8"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:paddingLeft="@dimen/abc_list_item_padding_horizontal_material"
        android:paddingRight="@dimen/abc_list_item_padding_horizontal_material"
        android:orientation="horizontal">

    </LinearLayout>

    <LinearLayout
        android:id="@+id/LLFav"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_weight="0.1"
        >

    </LinearLayout>
    <LinearLayout
        android:id="@+id/LLURL"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_weight="0.1"
        >

    </LinearLayout>

</LinearLayout>

我的问题是:我是否可以单独聚焦这三个LinearLayout,而不是整个项目(LLChannel)? 如何实现?

更新 17:12 10.07.2020:

为每个LinearLayout添加此内容并没有帮助我:

android:background="@drawable/item_touch_selector"
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusRight="@id/LLFav"

更新于2020年12月7日: 有任何想法如何达到这个目标吗?

更新于2020年12月13日: 这很容易。稍后我会回答自己的问题。

1个回答

0
所有的LinearLayout都必须再包裹在一个LinearLayout中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接