android - 在recyclerview项目android中更改视图之间的焦点
问题描述
我正在为 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>
我的问题是:我可以分别关注这三个 LinearLayouts 而不是全部项目(LLChannel)焦点吗?如何?
UPD 17:12 10.07.2020:
为每个 LinearLayout 添加这些东西对我没有帮助:
android:background="@drawable/item_touch_selector"
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusRight="@id/LLFav"
UPD 12.07.2020:有什么想法可以实现吗?
UPD 13.07.2020:这很容易。我稍后会回答我自己的问题。
解决方案
所有的 LinearLayout 都必须再包装在一个 LinearLayout 中。
推荐阅读
- c++ - c ++算法比较各种长度向量并隔离“唯一”,有点
- javascript - 多语言网站- 需要在每个页面上进行语言设置,如何避免这种情况?
- c# - 使用 NetOffice 在 Excel 中创建名称范围会引发 COMException
- c++ - 带有过滤器的现代迭代 C++ 集合
- apache-spark - org.apache.spark.shuffle.FetchFailedException:来自 server1/xxx.xxx.x.xxx:7337 的连接已关闭
- javascript - 如何让网页重定向?
- javascript - 如果菜单名称包含在允许的菜单字符串数组中,则过滤深层嵌套菜单数组
- discord.py - Discord.py - 如果提到特定用户,如何删除消息
- amazon-web-services - Elastic Beanstalk 中的权限被拒绝
- html - 如何在 html 和 Angular 中创建动态表