F
F
fenucss2021-01-25 14:15:36
Java
fenucss, 2021-01-25 14:15:36

Slow loading RecyclerView, what to do?

I want to add elements above the list that will go beyond the screen when scrolling the recycler view. The problem is that when the recyclerview is inside the nestedScroll, the list takes a very long time to load because it contains all the products from the database. If you take the list out of the recycler view, then it works perfectly without brakes. But in this case, when scrolling, the top element hangs above the list, and does not go off the screen. Who will advise what?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:padding="6dp">

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:id="@+id/but1"
    android:layout_marginBottom="10dp"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/imgcl"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            android:src="@drawable/yandex_logo_en"/>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/imgcl"
            android:scrollbars="none" />

    </RelativeLayout>
</androidx.core.widget.NestedScrollView>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2021-01-25
@fenucss

This is solved very simply - the elements "above the list" are entered into the list itself, the nested scroll is thrown out. See getItemViewType in adapter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question