1

This layout takes around 60 seconds to show up on screen but scrolling is fast as soon as it is done. The app freezes whilst this happens and works okay as soon as the the items of the lists show up on screen.I am loading around 400 contacts for the one list and around 10 for the second.This could vary since some phones could have more or less the number of contacts.

I also have this search/filter mechanism to show contacts that match a query. It works but updating the recyclerviews takes a very long time.

I am updating both recyclerviews according to the same filter/query.

What could be causing this slowdown?

How can I improve the time it takes for the layout to show/render on screen?

I used mKambaContactsListView?.isNestedScrollingEnabled = false and that helped improved the scrolling performance.

Any help would be appreciated.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/white"
        app:title="@string/title_pagar">

        <include
            android:id="@+id/olo"
            layout="@layout/search"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


        <android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="60dp"
            tools:context="tetst.com.contactstest.MainActivity">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="900dp">


                <android.support.constraint.ConstraintLayout
                    android:id="@+id/constraintLayout"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_bias="0.0"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="parent"
                    app:layout_constraintVertical_bias="0.006">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/kambaContactList"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:clipChildren="true"
                        android:clipToPadding="true"
                        app:layout_constraintBottom_toTopOf="@+id/local_tv"
                        app:layout_constraintHorizontal_bias="1.0"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/kamba_tv"
                        tools:listitem="@layout/kamba_contacts_item_layout" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/contactList"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="8dp"
                        android:clipChildren="true"
                        android:clipToPadding="true"
                        app:layout_constraintBottom_toBottomOf="parent"
                        app:layout_constraintHorizontal_bias="0.0"
                        app:layout_constraintLeft_toLeftOf="parent"
                        app:layout_constraintRight_toRightOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/local_tv"
                        tools:listitem="@layout/contacts_item_layout" />

                    <TextView
                        android:id="@+id/local_tv"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:paddingTop="8dp"
                        android:text="@string/local_contacts"
                        android:textAllCaps="true"
                        android:textColor="@color/text_dark_grey"
                        android:textStyle="bold"
                        app:layout_constraintBottom_toTopOf="@+id/contactList"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toBottomOf="@+id/kambaContactList" />

                    <TextView
                        android:id="@+id/kamba_tv"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="8dp"
                        android:paddingTop="8dp"
                        android:text="Kambas"
                        android:textAllCaps="true"
                        android:textColor="@color/text_dark_grey"
                        android:textStyle="bold"
                        app:layout_constraintEnd_toEndOf="parent"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </android.support.constraint.ConstraintLayout>
            </RelativeLayout>
        </android.support.v4.widget.NestedScrollView>
    </FrameLayout>**strong text**
  • What is the data you are showing? Have you times where the bottleneck is, are you sure it is the display rather than the actual query? Where is the filter code? Is it faster without the filter? Is it faster with fewer contacts? 400 is not a lot of data – Richard Le Mesurier Mar 26 '18 at 17:36

1 Answers1

0

I read place scrolling views such RecyclerView inside another ScrollView and NestedScrolView can create huge performance problems. There are several topics about it here: Topic 1-Topic 2

For example you can try adding android:nestedScrollingEnabled="false" to your RecyclerViews and see if it improves performance.

May This is one of your performance problem?

Afshin
  • 8,839
  • 1
  • 18
  • 53