您可以通过以下布局来实现:
<android.support.design.widget.CoordinatorLayout
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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!-- HEADER -->
<RelativeLayout
...
app:layout_collapseMode="parallax">
.....
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
<!-- IF YOU WANT TO KEEP "Choose Item" always on top of the RecyclerView, put this TextView here
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="choose item" />
-->
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
通过使用
app:layout_collapseMode="pin"
属性集。你使
RecyclerView
通过设置可正确滚动
app:layout_behavior="@string/appbar_scrolling_view_behavior"
差不多就是这样。
NB!
“选择项目”的位置
TextView
取决于您想要实现的特定行为:
-
您可以将其作为您的
回收站视图
的
Adapter
一旦用户开始滚动
回收站视图
;
-
您可以将其添加到
AppBarLayout
所以它会一直粘在
回收站视图
,无论您是否滚动;
你可以在这里阅读更多
Android Design Support Library
还有这里
Design Support Library (III): Coordinator Layout
我希望,这有帮助!