Навигация по Dpad не работает на телевизоре для просмотра реселлера, который находится под Appbarlayout (представление реселлера не фокусируется на dpad) - PullRequest
0 голосов
/ 12 апреля 2019

У меня есть RecyclerView под Appbarlayout, у меня есть панель инструментов внутри appbarlayout и она становится сфокусированной.я хочу использовать элементы управления Dpad для навигации по программе повторного просмотра, чего я не могу сделать.Любая помощь очень ценится.

Я пытался установить 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>

1 Ответ

1 голос
/ 12 апреля 2019

Вместо того, чтобы фокусировать RecyclerView и его родительский RelativeLayout, я сделал фокусировку на представление элементов RelativeLayout, и это сработало. Спасибо ataulm:)

...