My problem nestedscrollview inside recylerview when I loaded more page which does not work scroll smoothly or fastly.Also I added rec_detail_videos.setNestedScrollingEnabled(false); this one still my scroll listener does not work smoothly. Briefly, when I loaded 100 pages approximately after my scrollview worked slowly.

I also tried to made rootview to Cordinatorlayout but it does not work Also, I found these links https://stackoverflow.com/questions/44580892/recycler-view-loading-very-slow-for-large-data-when-inside-nestedscrollview and

Bad performance when use RecyclerView inside NestedScrollView but I need a solution for these issues how can I figure out without my code cover to multiple recylerview ?

 @androidx.annotation.RequiresApi(api = Build.VERSION_CODES.M)
    public void setOtherVideoMoreAdapter() {
        nestedScrollView = detailFragment.findViewById(R.id.sv_scroll);
       LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        rec_detail_videos.setLayoutManager(linearLayoutManager);
        rec_detail_videos.setNestedScrollingEnabled(false);
       nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                if(v.getChildAt(v.getChildCount() - 1) != null) {
                    if ((scrollY >= (v.getChildAt(v.getChildCount() - 1).getMeasuredHeight() - v.getMeasuredHeight())) &&
                            scrollY > oldScrollY) {
                        //code to fetch more data for endless scrolling
                        if (videosAdapter != null) {
                            if(haveMoreNews) {
                                loadNextDataFromApi(page);
                                final int curSize = videosAdapter.getItemCount();
                                videosAdapter.notifyItemRangeInserted(curSize, videosList.size() - 1);
                            }
                    }
                }

                }
            }
        });

    }

// I added my layout xml code below

<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:id="@+id/sv_scroll"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:isScrollContainer="false"
    android:layout_below="@+id/appbar"
    android:fillViewport="true">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        android:orientation="vertical">

        <include
            android:id="@+id/layout_video_detail"
            layout="@layout/layout_news_detail"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="gone" />
    </LinearLayout>
</android.support.v4.widget.NestedScrollView>

// include -> layout_news_detail

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <RelativeLayout
        android:id="@+id/rl_button_more"
        android:layout_width="300dp"
        android:layout_height="40dp"
        android:layout_below="@+id/rec_other_videos"
        android:layout_centerInParent="false"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:layout_marginBottom="50dp"
        android:background="@drawable/ic_load_more_video"
        android:visibility="gone">

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="DAHA FAZLA VİDEO" />
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_other_video"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rl_info_line2"
        android:layout_marginTop="10dp">

        <TextView
            android:id="@+id/tv_title_video"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:textColor="@color/aksamTv_title"
            android:textStyle="bold"
            app:fontFamily="@font/roboto_bold"
            tools:text="Diğer Videolar" />
    </RelativeLayout>


    <android.support.v7.widget.RecyclerView
        android:id="@+id/rec_other_videos"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rl_other_video"
        android:layout_marginLeft="5dp"
        android:layout_marginTop="5dp"
        android:layout_marginRight="5dp"
        android:clipToPadding="false"
        android:scrollbars="vertical"
        app:layoutManager="android.support.v7.widget.LinearLayoutManager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        tools:listitem="@layout/layout_aksamtv_detail_other_videos" />

    <RelativeLayout
        android:id="@+id/rl_main_info"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/main_media_frame">

        <ImageView
            android:id="@+id/iv_time"
            android:layout_width="wrap_content"
            android:layout_height="15dp"
            android:layout_below="@+id/tv_lastshort_title"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:src="@drawable/ic_access_time_black_24dp" />

        <TextView
            android:id="@+id/tv_date"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/tv_lastshort_title"
            android:layout_marginLeft="5dp"
            android:layout_marginTop="5dp"
            android:layout_toRightOf="@+id/iv_time"
            tools:text="09.04.2019" />

        <TextView
            android:id="@+id/tv_lastshort_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginTop="10dp"
            android:textColor="@color/aksamTv_title"
            android:textStyle="bold"
            app:fontFamily="@font/roboto_bold"
            tools:text="Fatih in veliahtı : Cem Sultan " />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_info_line"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_below="@+id/rl_main_info"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="2dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="2dp"
        android:background="#E8E8E8" />


    <RelativeLayout
        android:id="@+id/rl_info_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rl_info"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp">

        <TextView
            android:id="@+id/tv_info_more"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            tools:text="" />
    </RelativeLayout>


    <FrameLayout
        android:id="@+id/main_media_frame"
        android:layout_width="match_parent"
        android:layout_height="215dp"
        android:background="#000000">
        <com.google.android.exoplayer2.ui.SimpleExoPlayerView
            android:id="@+id/detail_video_simple"
            android:layout_width="match_parent"
            android:layout_height="215dp"></com.google.android.exoplayer2.ui.SimpleExoPlayerView>
    </FrameLayout>


    <RelativeLayout
        android:id="@+id/rl_info"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/rl_info_line">

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="false"
            android:layout_marginLeft="15dp"
            android:textColor="@color/aksamTv_title"
            android:textStyle="bold"
            app:fontFamily="@font/roboto_bold"
            tools:text="DİYET MUTFAĞI" />

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/rl_info_line2"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_below="@+id/rl_info_text"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="5dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="2dp"
        android:background="#E8E8E8" />
</RelativeLayout>

when I loaded on 100 items why scrollview working slow

0 Answers