android - Stop Scrolling for CollapsingToolbarLayout when showing a Fragment -
i have viewpager
inside activity
shows 2 fragments
.
the activity has tablayout
, collapsingtoolbarlayout
. collapsingtoolbarlayout
nested inside appbarlayout
imageview
produce parallax effect. tablayout
outside appbarlayout
inside linearlayout
viewpager
. there framelayout
show fragment
on viewpager
when user clicks button show fragment
.
the problem when scroll recyclerview
inside fragment
overlays on top of viewpager
activity
scrolls , parallax effect. scrolls both recyclerview
inside fragment
, content inside viewpager
well.
is there way stop scrolling collapsingtoolbarlayout
, scroll content in overlay fragment
when user sees fragment
?
this xml hierarchy looks like:
<android.support.design.widget.coordinatorlayout> <android.support.design.widget.appbarlayout> <android.support.design.widget.collapsingtoolbarlayout app:layout_scrollflags="scroll|exituntilcollapsed"> <imageview app:layout_collapsemode="parallax"/> <android.support.v7.widget.toolbar /> </android.support.design.widget.collapsingtoolbarlayout> </android.support.design.widget.appbarlayout> <linearlayout app:layout_behavior="@string/appbar_scrolling_view_behavior" > <android.support.design.widget.tablayout /> <!-- 2 fragments inside viewpager each containing recyclerview --> <android.support.v4.view.viewpager /> </linearlayout> <!-- user clicks button , fragment added framelayout --> <!-- fragment overlays on top of entire activity layout --> <!-- fragment contains recyclerview --> <framelayout/> </android.support.design.widget.coordinatorlayout>
the coordinatorlayout
, appbarlayout
operate via onnestedscroll
callbacks children. if have scrolling child, can stop effecting parent/s disabling callback:
recyclerview.setnestedscrollingenabled(false);
Comments
Post a Comment