嵌套滚动视图中的 ESRI 地图
ESRI map inside a Nested Scroll View
我正在尝试将 ESRI 地图添加到我位于 NestedScrollView 中的片段。它加载正常,但是当我移动地图时,如果我删除 NestedScrollView 一切正常。
这是我在 NestedScrollView 中的 ESRI 地图视图
<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>
我尝试将 customTouchListener 设置为从 here 引用的地图视图,例如:
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
}
}
还是一样的问题,地图移动不流畅
它将禁止 scrollView 拦截 mapView 的触摸事件
override fun onTouch(view: View?, event: MotionEvent?): Boolean {
activity?.nestedScrollView?.requestDisallowInterceptTouchEvent(true)
return super.onTouch(view, event)
}
也在addViewpointChangedListener
中进行
mapView.addViewpointChangedListener {
activity?.nestedScrollView?.requestDisallowInterceptTouchEvent(true)
}
我正在尝试将 ESRI 地图添加到我位于 NestedScrollView 中的片段。它加载正常,但是当我移动地图时,如果我删除 NestedScrollView 一切正常。
这是我在 NestedScrollView 中的 ESRI 地图视图
<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>
我尝试将 customTouchListener 设置为从 here 引用的地图视图,例如:
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
}
}
还是一样的问题,地图移动不流畅
它将禁止 scrollView 拦截 mapView 的触摸事件
override fun onTouch(view: View?, event: MotionEvent?): Boolean {
activity?.nestedScrollView?.requestDisallowInterceptTouchEvent(true)
return super.onTouch(view, event)
}
也在addViewpointChangedListener
mapView.addViewpointChangedListener {
activity?.nestedScrollView?.requestDisallowInterceptTouchEvent(true)
}