I am trying to add ESRI map to my fragment which is in a NestedScrollView. It is loaded fine but when I move the map it is not moving smoothly if I remove NestedScrollView everything works fine.
Here is my ESRI map view inside NestedScrollView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/spacing_normal">
<com.esri.arcgisruntime.mapping.view.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.esri.arcgisruntime.mapping.view.MapView>
</androidx.core.widget.NestedScrollView>
</LinearLayout>
I tried by setting customTouchListener to map view by referred from here like:
MyTouchListener tl = new MyTouchListener(this, mMapView);
mMapView.setOnTouchListener(tl);
MyTouchListener class:
class MyTouchListener(context: Context, m: MapView) : DefaultMapViewOnTouchListener(context, m) {
private var sv: NestedScrollView? = null
override fun onTouch(v: View?, event: MotionEvent): Boolean {
v?.performClick()
sv = v!!.findViewById(R.id.nestedScrollView)
val action = event.action
when (action) {
MotionEvent.ACTION_DOWN ->
// will disable the scrollview from being able to
// intercept the touch events for the mapview
sv?.requestDisallowInterceptTouchEvent(true)
MotionEvent.ACTION_UP ->
// gives control back over to the scrollview
sv?.requestDisallowInterceptTouchEvent(false)
}
super.onTouch(v, event)
return true
}
}
But still the same issue, the map is not moving smoothly.
It will disable the scrollView from being able to intercept the touch events for the mapView
override fun onTouch(view: View?, event: MotionEvent?): Boolean {
activity?.nestedScrollView?.requestDisallowInterceptTouchEvent(true)
return super.onTouch(view, event)
}
Also do it in addViewpointChangedListener
mapView.addViewpointChangedListener {
activity?.nestedScrollView?.requestDisallowInterceptTouchEvent(true)
}