1

Haven't found a question/answer for this. When you put a Google Map inside a RecycleView (I'm using MapView inside a ViewHolder), the scrolling only works from left-to-right. Up-down scrolling is taken up by the RecycleView. Is there a way to provide normal (one finger) scrolling for the map view?

Thanks

breakline
  • 5,776
  • 8
  • 45
  • 84
  • check it -https://stackoverflow.com/questions/33153123/mapview-inside-nestedscrollview-not-scrolling – Adil Oct 08 '18 at 06:13

2 Answers2

0

RecycleView get by default up and down surface scroll. You have to separate it from the main view. By using NestedScrollView you can get this. Put your googlemap in NestedScrollView.

pavel
  • 1,603
  • 22
  • 19
0

This is how I've solved this -

I've created a custom view extending mapView and override dispatchTouchEvent()

class CustomMapView(context: Context, attrs: AttributeSet?): MapView(context, attrs) {

override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
    this.performClick()
    when (ev.action) {
        MotionEvent.ACTION_DOWN ->         // Disallow ScrollView to intercept touch events.
            this.parent.requestDisallowInterceptTouchEvent(true)
        MotionEvent.ACTION_UP ->         // Allow ScrollView to intercept touch events.
            this.parent.requestDisallowInterceptTouchEvent(false)
    }

    // Handle MapView's touch events.
    super.dispatchTouchEvent(ev)
    return true
    }
}

and used this to my xml -

    <com.demo.android.demo.ui.base.customviews.CustomMapView
        android:id="@+id/map_placeholder"
        android:layout_width="0dp"
        android:layout_height="700dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        map:mapType="none" />
mefahimrahman
  • 197
  • 2
  • 6
  • 29