我有一个ViewPager
里面Activity
显示两个Fragments
。
该活动有一个TabLayout
和一个CollapsingToolbarLayout
。CollapsingToolbarLayout
嵌套在 中以AppBarLayout
产生ImageView
视差效果。TabLayout
是外内AppBarLayout
一LinearLayout
与ViewPager
。然后当用户单击一个按钮来显示那个时,还有一个FrameLayout
显示另一个。Fragment
ViewPager
Fragment
问题是,当您滚动覆盖在其顶部的内部RecyclerView
时,也会滚动并产生视差效果。本质上,它同时滚动内部和内部的内容。Fragment
ViewPager
Activity
RecyclerView
Fragment
ViewPager
有没有办法在用户看到时停止滚动CollapsingToolbarLayout
并且只滚动覆盖层中的内容?Fragment
Fragment
这就是我的 XML 层次结构的样子:
<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 />
<!-- Two fragments inside ViewPager each containing a RecyclerView -->
<android.support.v4.view.ViewPager />
</LinearLayout>
<!-- User Clicks a button and fragment is added to this framelayout -->
<!-- This fragment overlays on top of the entire Activity layout -->
<!-- This fragment also contains a recyclerview -->
<FrameLayout/>
</android.support.design.widget.CoordinatorLayout>