前言:项目中在开发吸顶布局的时候使用了CoordinatorLayout和AppBarLayout实现,布局包括CoordinatorLayout、CollapsingToolbarLayout 、AppBarLayout、ToolBar和RecyclerView这五个类,
但是给CollapsingToolbarLayout 添加了app:layout_scrollFlags=snap属性之后,轻轻滑动的时候在snap阀值的地方会有一个卡顿的过程然后会继续滑动到结束。
1.首先看下xml布局文件:
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/AppFragment_AppBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_behavior="com.boco.whl.funddemo.module.adapter.behavior.WhlBehavior">
android:id="@+id/AppFragment_CollapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7">
android:id="@+id/AppFragment_Toolbar"
android:layout_width="match_parent"
android:layout_height="76dp"
android:paddingTop="20dp"
app:layout_collapseMode="pin">
android:layout_width="match_parent"
android:layout_height="56dp">
android:id="@+id/MyFragment_recyclerView"
android:layout_width="match_parent"
<