将 NestedScrollView 应用于活动后,工具栏不会随内容一起滚动。我尝试了许多滚动选项和标志。高度和宽度参数这里就不写了。
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed"
app:collapsedTitleGravity="fill_vertical">
<android.support.v7.widget.Toolbar
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:overScrollMode="always"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="a.fruitsbook.ScrollingActivity"
tools:showIn="@layout/activity_scrolling"
android:overScrollMode="always">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewScroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>