Scrolling Outer recyclerview to show inner recyclerview + section title

57 views Asked by At
<?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>

I have the following layout for an inner recyclerView that is part of an outer vertical recyclerView that contains multiple horizontal recyclerViews. As you can see in the layout above, each inner recyclerView has a section header, but when scrolling up the vertical recyclerView, it ends up only focusing the horiztonal recyclerview item and the TextView is just hidden and needs another tap up the dpad to show. How can I make the vertical recyclerView show the title when scrolling up.

I tried adding android:descendantFocusability="blocksDescendants" but that completely removes the focus from the Horiztonal RecyclerView items which I do not want.

1

There are 1 answers

0
MicroDev On BEST ANSWER

The solution was not to put the Outer recyclerView in a ScrollView and use a FrameLayout instead.