问题描述
<?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的一部分,其中包含多个水平recyclerViews。如您在上面的布局中看到的那样,每个内部recyclerView都有一个节标题,但是当向上滚动垂直recyclerView时,它最终仅聚焦于水平recyclerview项,并且TextView仅被隐藏并且需要再次轻按dpad才能显示。 向上滚动时,如何使垂直recyclerView显示标题。
我尝试添加android:descendantFocusability =“ blocksDescendants” 但这完全消除了我不希望使用的水平RecyclerView项目的焦点。
解决方法
解决方案不是将外部recyclerView放在ScrollView中,而是使用FrameLayout。