gpt4 book ai didi

android - Dpad 导航无法在 Appbarlayout 下方的 recyclerview 的电视上工作(recycler View 未通过 dpad 获得焦点)

转载 作者:行者123 更新时间:2023-12-04 23:56:41 27 4
gpt4 key购买 nike

我在 Appbarlayout 下方有 RecyclerView,我在 appbarlayout 内有工具栏,并且它越来越集中。我想要的是使用 Dpad 控件来导航我无法做到的 recyclerview。非常感谢任何帮助。

我尝试设置 android:focusable="true"但没有成功。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorBackground"
android:orientation="vertical">

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/tab_coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/tab_appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/AppTheme.AppBarOverlay">

<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways" />

</com.google.android.material.appbar.AppBarLayout>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="3dp"
android:scrollbars="none"
android:focusable="true"
android:descendantFocusability="afterDescendants"
android:scrollingCache="true" />

</RelativeLayout>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

最佳答案

我没有让 RecyclerView 及其父级 RelativeLayout 成为焦点,而是让项目 View RelativeLayout 成为焦点,并且成功了。感谢 ataulm :)

关于android - Dpad 导航无法在 Appbarlayout 下方的 recyclerview 的电视上工作(recycler View 未通过 dpad 获得焦点),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55653639/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com