'RecyclerView with horizontal and vertical scroll and fixed header on top and left

I have to implement a table like this, but I don't know how to handle all these scroll behaviors:

First image

Second image

Third image

I was already able to implement the table with all the values and the fixed header, but I am not able to fix the two columns at the left. This is my layout:

<HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="@dimen/dimen_0"
        android:layout_marginStart="@dimen/dimen_20"
        android:layout_marginTop="@dimen/dimen_20"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/operations_table_toolbar"
        app:layout_constraintVertical_bias="0.0">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/header_recycler_view"
                android:layout_width="@dimen/dimen_0"
                android:layout_height="@dimen/dimen_30"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rows_recycler_view"
                android:layout_width="wrap_content"
                android:layout_height="@dimen/dimen_0"
                android:layout_marginTop="@dimen/dimen_20"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/header_recycler_view" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </HorizontalScrollView>

The first recycler view is for the header views, where I am handling different types of views. The second one is a recycler view of recycler views.

Has someone a suggestion on how to do something like that? With ItemDecorators, CustomLayoutManagers, or something like that? The elevations are not important, but it is nice to have them.

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source