Dpad导航无法在电视上工作,回收器视图位于Appbarlayout下方(回收器视图无法通过dpad获得焦点)

问题描述 投票:0回答:1

我在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>

android android-recyclerview android-tv
1个回答
1
投票

我没有让RecyclerView及其父亲RelativeLayout成为焦点,而是让物品视图RelativeLayout成为可调焦点,并使其蓬勃发展。感谢ataulm :)

© www.soinside.com 2019 - 2024. All rights reserved.