0

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)

Example

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?

arekolek
  • 9,128
  • 3
  • 58
  • 79
  • You can review this. https://stackoverflow.com/questions/47646974/map-recyclerview-inside-scrollview-display-black-flickering-background-while-scr – Grishma Ukani Jul 01 '19 at 10:14
  • @GrishmaUkani Thanks, although I'm not sure how it's related. I don't want multiple maps, the one map has to be interactive (no lite mode), and I don't experience any flickering. – arekolek Jul 01 '19 at 10:25
  • why u put map inside nested scroll view? – unzila Jul 01 '19 at 10:40
  • @unzila I updated the question with a screencap of what the desired behavior is – arekolek Jul 01 '19 at 13:53

0 Answers0