Scrolling is not smooth while using 3 recyclerviews inside nestedscrollview in android -
i have 3 recyclerviews in single layout file have horizontally aligned layoutmanagers , these recyclerviews inside nestedscrollview , i've set nestedscrolling each of 3 recyclerviews false too.
<?xml version="1.0" encoding="utf-8"?> <framelayout 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:id="@+id/framelayout" android:background="@drawable/background"> <android.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="wrap_content"> <linearlayout android:id="@+id/linearlayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="vertical"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="5dp" android:text="free movies" android:textstyle="bold" android:textsize="18sp" android:textcolor="@color/coloraccent" /> <view android:id="@+id/recycler_view" class="android.support.v7.widget.recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerinparent="true" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="vertical"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="5dp" android:text="premium movies" android:textcolor="@color/coloraccent" android:textstyle="bold" android:textsize="18sp" /> <view android:id="@+id/recycler_view1" class="android.support.v7.widget.recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerinparent="true" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:orientation="vertical"> <textview android:id="@+id/tvtrending" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="5dp" android:text="packages" android:textcolor="@color/coloraccent" android:textstyle="bold" android:textsize="18sp" /> <view android:id="@+id/recycler_view2" class="android.support.v7.widget.recyclerview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerinparent="true" android:dividerheight="10.0sp" /> </linearlayout> </linearlayout> </android.support.v4.widget.nestedscrollview> <progressbar android:id="@+id/progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" android:layout_gravity="center"/> </framelayout>
and layout of fragment i've called viewpager mainactivity. has layout this
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" 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" tools:context="com.newitventure.musicnepal.mainactivity"> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/coordinatorlayout" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.appbarlayout android:id="@+id/tabanim_appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/themeoverlay.appcompat.dark.actionbar"> <include android:id="@+id/tool_bar" layout="@layout/toolbar" /> <android.support.design.widget.tablayout android:id="@+id/tablayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabmaxwidth="0dp" android:background="@color/colorprimarydark" app:tabgravity="fill" app:tabtextappearance="@style/mycustomtextappearance" app:tabmode="scrollable" /> </android.support.design.widget.appbarlayout> <android.support.v4.view.viewpager android:id="@+id/tabanim_viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginbottom="50dp" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </android.support.design.widget.coordinatorlayout> <linearlayout android:id="@+id/gad_bottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_gravity="bottom" android:orientation="horizontal" android:visibility="visible"> </linearlayout> </relativelayout>
the problem while trying scroll in layout scrolling not smooth. gets laggy while trying scroll both vertically , horizontally. might issue here?
okay,
i see 3 possibilities code given
1) you're using relativelayout @ root views. while relativelayout awesome lot, have drawbacks. due how relativelayout built measures twice , children in it. every frame displayed android needs recalculate every view twice.
2) have "rather" deep structure on views , think example can rid of each of 3 linear layouts have around pair of textview , recycleview.
3) you're doing heavy in bindview method when displaying recyclerviews.
now 3 of these matter , play role in making laggy. start 2 (i don't think alone solve completely, should improve readability , speed of code) check 3 (if paste code adapter have on if there's clear there). if still doesn't try 1 (which can hard relativelayout structuring code)
hope helps!
Comments
Post a Comment