我目前正在尝试创建项目列表,例如频道列表。我有一个RecyclerView,并为我的RecyclerView使用LinearLayoutManager。但是我似乎无法使用d-pad控件上下浏览RecyclerView,但是我可以左右导航
RecyclerView channelsRV = findViewById(R.id.rv_items);
LinearLayoutManager layoutManager = new LinearLayoutManager(this,LinearLayoutManager.VERTICAL, false);
channelsRV.setLayoutManager(layoutManager);
这是rv列表
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_channels"
android:layout_width="200dp"
android:layout_height="0dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/rv_packages"
app:layout_constraintTop_toTopOf="parent" />
这是物品
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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:layout_width="match_parent"
android:layout_height="@dimen/item_height"
android:layout_margin="2dp"
android:focusable="true">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black_transparent">
<ImageView
android:id="@+id/iv_channel_image"
android:layout_width="50dp"
android:layout_height="46dp"
android:layout_marginStart="2dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_channel_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
android:textColor="@android:color/white"
android:textSize="@dimen/small_txt_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/iv_channel_image"
app:layout_constraintTop_toTopOf="parent"
tools:text="001" />
<TextView
android:id="@+id/tv_channel_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="2dp"
android:ellipsize="marquee"
android:enabled="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="@android:color/white"
android:textSize="@dimen/small_txt_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_channel_number"
app:layout_constraintTop_toTopOf="parent"
tools:text="BR Discovery Civilization" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>