android - Recyclerview inside ViewPager which is inside nested Scroll View -
i have used following code inside coordinator layout , using custom collapsing toolbar design.
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout 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" tools:ignore="rtlhardcoded"> <android.support.design.widget.appbarlayout android:id="@+id/main.appbar" android:layout_width="match_parent" android:layout_height="250dp" android:background="@drawable/backg"> <android.support.design.widget.collapsingtoolbarlayout android:id="@+id/main.collapsing" android:layout_width="match_parent" android:layout_height="250dp" app:contentscrim="?attr/colorprimary" app:layout_scrollflags="scroll|exituntilcollapsed|snap"> <framelayout android:id="@+id/main.framelayout.title" android:layout_width="match_parent" android:layout_height="130dp" android:layout_gravity="bottom" android:background="#00000000" android:orientation="vertical" app:layout_collapsemode="parallax" app:layout_collapseparallaxmultiplier="0.3"> <linearlayout android:id="@+id/main.linearlayout.title" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingleft="30dp" android:layout_gravity="left" android:orientation="vertical"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="bottom" android:text="user name" android:id="@+id/username" android:textcolor="@android:color/white" android:textsize="30sp"/> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="4dp" android:id="@+id/business" android:text="users business" android:textcolor="@android:color/white"/> </linearlayout> </framelayout> <android.support.v7.widget.toolbar android:id="@+id/main.toolbar" android:layout_width="match_parent" android:layout_height="110dp" android:background="#00000000" app:theme="@style/themeoverlay.appcompat.dark.actionbar" app:title="" app:layout_collapsemode="pin"> <linearlayout android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal"> <imageview android:layout_width="32dp" android:layout_height="32dp" android:id="@+id/back" android:layout_margintop="10dp" android:background="@drawable/ic_arrow_back"/> <textview android:id="@+id/main.textview.title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" android:text="user name" android:textcolor="@android:color/white" android:textsize="24sp" /> </linearlayout> </android.support.v7.widget.toolbar> <android.support.design.widget.tablayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#00000000" android:layout_gravity="bottom" app:tabmode="fixed" app:tabgravity="fill" app:theme="@style/themeoverlay.appcompat.dark.actionbar"/> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <android.support.v4.widget.nestedscrollview android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:layout_gravity="fill_vertical" android:fillviewport="true" android:layout_marginbottom="110dp"> <android.support.v4.view.viewpager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_gravity="fill_vertical" android:layout_height="match_parent" android:background="@android:color/white"> </android.support.v4.view.viewpager> </android.support.v4.widget.nestedscrollview> </android.support.design.widget.coordinatorlayout>
now problem facing is, when run app on lower os versions, okay while scrolling in viewpager fragments recyclerviews, when use os above android.m, recyclerview's height out of display screen, , not visible enough see item on screen. please me resolve problem. have designed custom collapsing bar layout, okay in lower android os.
[edited]
here snapshots when add margin_bottom of actionbar size.
<--- snapshot end.
you can see viewpagers height less screen size using marginbottom.
now
for higher varients, okay below while using marginbottom.
thanks reviews , answers questions, after digging didnt found useful, , though set height programmatically. tried snippet below, , works charm. heigher varients, set marginbottom actionbar size in layout xml in nestedscrollview , lower varients, use hack below.
nestedscrollingview nsv = findviewbyid(r.id.nsv); if (android.os.build.version.sdk_int < android.os.build.version_codes.m){ android.support.design.widget.coordinatorlayout.layoutparams lpm = new android.support.design.widget.coordinatorlayout.layoutparams( android.support.design.widget.coordinatorlayout.layoutparams.match_parent, android.support.design.widget.coordinatorlayout.layoutparams.match_parent); lpm.setmargins(0,0,0,0); lpm.setbehavior(new android.support.design.widget.appbarlayout.scrollingviewbehavior()); nsv.setlayoutparams(lpm); nsv.requestlayout(); }
again, help.
Comments
Post a Comment