Farouk Sabiou
Farouk Sabiou

Reputation: 121

How to have two recyclerview (horizontal first then vertical) in the same Layout with smaooth scroll

I have two recyclerview (horizontal first, then vertical) in the same layout, I want the two to scroll up together so I used NestedScrollView but it come with some serious scrolling issue. It lag and cause crash some time.

I already saw some folks suggested using nestedScrollingEnabled = "false" in the RecyclerView but I already tried and nothing still no result.

Any idea on how to achieve this ?

Here's the xml btw

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/appbar"
            android:clipToPadding="false"
            android:orientation="vertical">

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/stories_recycler_view"
                storiesData="@{viewModel.stories}"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                android:orientation="horizontal"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                tools:listitem="@layout/item_story" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/posts_recycler_view"
                feedListData="@{viewModel.entries}"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                android:orientation="vertical"
                app:stackFromEnd="true"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                app:paddingBottomSystemWindowInsets="@{true}"
                app:paddingTopSystemWindowInsets="@{true}"
                app:reverseLayout="true"
                tools:listitem="@layout/item_text_post" />

        </LinearLayout>

Upvotes: 0

Views: 310

Answers (2)

Jaimil Patel
Jaimil Patel

Reputation: 1347

 <androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">

<LinearLayout>
...
Add `android:nestedScrollingEnabled="true"` in both Recyclerview Tag...<br>
...
</LinearLayout>

<androidx.core.widget.NestedScrollView/>

Upvotes: 0

Yuza
Yuza

Reputation: 19

post your XML code and what did you mean by both scrolling up? horizontal views don't go upwards

Upvotes: 0

Related Questions