假设我有这样的布局:
<androidx.core.widget.NestedScrollView
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"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="300dp"
app:uiMapToolbar="false"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
这符合我的需求,即
我发现有两个问题:
我也尝试过将地图作为适配器的一项,但是在滚动列表时会引入很多麻烦,而且很尴尬,因为您需要将转发生命周期与地图的回收期适配器中的项的“生命周期”协调起来
那么您如何在列表下显示地图而又不会丢失回收或平滑滚动?