【发布时间】:2020-09-23 18:51:47
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:focusable="false"
android:focusableInTouchMode="false"
android:textColor="@color/white"
android:id="@+id/section_title"
android:textSize="@dimen/_10ssp"
android:layout_width="wrap_content"
android:padding="8dp"
android:layout_height="wrap_content"/>
<com.PersistentFocusWrapper
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.TvRecyclerView
android:layout_below="@id/section_title"
android:id="@+id/CarouselsRowRv"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="horizontal"
android:layout_width="match_parent"
app:tv_selectedItemOffsetEnd="658dp"
android:layout_height="125.4dp" />
</com.PersistentFocusWrapper>
</LinearLayout>
我有一个内部 recyclerView 的以下布局,它是包含多个水平 recyclerView 的外部垂直 recyclerView 的一部分。正如您在上面的布局中看到的,每个内部 recyclerView 都有一个节标题,但是当向上滚动垂直 recyclerView 时,它最终只聚焦水平 recyclerview 项目,TextView 只是隐藏,需要再次点击 dpad 才能显示。 如何让垂直 recyclerView 在向上滚动时显示标题。
我尝试添加 android:descendantFocusability="blocksDescendants" 但这完全消除了我不想要的水平 RecyclerView 项目的焦点。
【问题讨论】:
标签: android xml android-recyclerview nestedrecyclerview