向上滑动的时候头部隐藏
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/appWhite">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@android:style/ThemeOverlay.Material.ActionBar">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/ctlToolBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="@color/appWhite"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
app:statusBarScrim="@android:color/transparent"
app:titleEnabled="false">
<RelativeLayout
android:id="@+id/rlMap"
android:layout_width="match_parent"
android:layout_height="@dimen/qb_px_250"
android:background="@color/appWhite">
<com.amap.api.maps.TextureMapView
android:id="@+id/mvMapView"
android:layout_width="match_parent"
android:layout_height="@dimen/qb_px_250"
android:background="@android:color/white" />
<ImageView
android:id="@+id/ivLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="@dimen/qb_px_8"
android:layout_marginBottom="@dimen/qb_px_8"
android:src="@mipmap/location_back" />
</RelativeLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
本文介绍了一种实现地图视图与RecyclerView滚动联动的方法,通过使用CoordinatorLayout、AppBarLayout和CollapsingToolbarLayout组件,当用户向上滑动时,地图视图逐渐隐藏并展示下方的列表内容,提供流畅的用户体验。
1885

被折叠的 条评论
为什么被折叠?



