如何在Android TV应用中使用RecyclerView?

问题描述

我正在Android TV应用程序中使用RecyclerView。当我使用D-pad时会发生焦点移动。

例如,当我右转3次时,它就会下降。

您在Android电视应用程序中使用哪种结构?我在等你的建议。 我必须解决错误

我的布局文件如下:

<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.SlidingPaneLayout
    android:background="#000000"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/sPanelLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.constraint.ConstraintLayout

        android:id="@+id/clSlideMenu"
        android:layout_width="60dp"
        android:layout_height="match_parent"
        android:background="#000000"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/ivlogo"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginStart="1dp"
            android:layout_marginTop="4dp"
            android:background="@drawable/atlasnewlogo"
            android:scaleType="center"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <android.support.v7.widget.RecyclerView

            android:id="@+id/rvLeftMenu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="4dp"
            android:layout_marginBottom="16dp"
            android:background="#000000"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/ivlogo"
            app:layout_constraintVertical_bias="0.0"
            tools:layout_editor_absoluteX="4dp" />

    </android.support.constraint.ConstraintLayout>


    <android.support.constraint.ConstraintLayout
        android:background="#000000"
        android:id="@+id/flContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="55dp"
        android:textSize="40sp">


        <android.support.v4.widget.nestedScrollView
            android:background="#000000"
            android:layout_width="match_parent"
            android:layout_height="match_parent">


            <android.support.constraint.ConstraintLayout
                android:id="@+id/clMain"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#000000">


                <TextView
                    android:id="@+id/textView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="4dp"
                    android:text="Now on Tv"
                    android:textColor="#ffffff"
                    android:textSize="20sp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/slMainboard" />


                <android.support.v7.widget.RecyclerView
                    android:focusable="false"
                    android:id="@+id/rvNowPlayProgram"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="4dp"
                    android:background="#000000"
                    app:layout_constraintTop_toBottomOf="@+id/textView"
                    tools:layout_editor_absoluteX="0dp">

                </android.support.v7.widget.RecyclerView>


                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rvContent"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="8dp"
                    android:background="#000000"
                    android:nestedScrollingEnabled="false"
                    app:layout_constraintTop_toBottomOf="@+id/rvNowPlayProgram"
                    tools:layout_editor_absoluteX="0dp">

                </android.support.v7.widget.RecyclerView>


                <com.saatteknoloji.atlastv.ui.home.slider.SliderLayout
                    android:id="@+id/slMainboard"
                    android:layout_width="match_parent"
                    android:layout_height="380dp"
                    android:background="#000000"
                    app:layout_constraintTop_toTopOf="parent"
                    tools:layout_editor_absoluteX="0dp">


                </com.saatteknoloji.atlastv.ui.home.slider.SliderLayout>


            </android.support.constraint.ConstraintLayout>


        </android.support.v4.widget.nestedScrollView>
    </android.support.constraint.ConstraintLayout>

</android.support.v4.widget.SlidingPaneLayout>

如何解决错误

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)