Let's say I have a layout like this:
<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>
It would fit my needs, that is
- Display a map under a list, in a way that the map is displayed under the last item of the list
- Lets the map receive touch input from the user, so it can be panned, zoomed, etc. (no Lite Mode)
There are two problems that I see with it though:
- There's no recycling, which means the memory required to render the list will increase with the number of items that are on the list. I don't expect to have more than 200 relatively simple items on the list, and after profiling I might say this is not that big of a problem, but of course I'd prefer to keep recycling.
- The list has to have expandable items, which means the user can click on some item and the recycler will then add/remove items from the list. If the expanded group has a lot of items, the measurement takes a lot of time, causing significant jank in the expanding animation, which is not acceptable.
I also tried making the map an item of the adapter, but it introduces a lot of jank when scrolling the list and is awkward since you need to reconcile forwarding lifecycle to the map with the "lifecycle" of items in the recycler adapter.
So how do you display a map under a list without losing recycling or smooth scrolling?