android - 嵌套滚动视图中的 ESRI 映射
问题描述
我正在尝试将 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 设置为映射视图,例如:
MyTouchListener tl = new MyTouchListener(this, mMapView);
mMapView.setOnTouchListener(tl);
MyTouchListener 类:
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
}
}
但还是同样的问题,地图移动不顺畅。
解决方案
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)
}
推荐阅读
- javascript - 如何在表格中搜索 HTML img 标题属性?
- extract - 从 BW 图像中提取形状
- c# - 在 C# 中存储敏感数据的最佳方法(KeePass、Symmetric Encryp.、..)
- schema - Magento 1 模式标记
- opencv - 在 OPENCV 中有 'stereoRectify' 的逆运算吗?
- django - django.core.exceptions.ImproperlyConfigured:禁止创建没有“字段”属性或“排除”属性的 ModelForm。需要
- python - Plotly Dash 与 Django 集成:在侧边栏应用导航时,当前路径welcome.html 与其中任何一个都不匹配
- android - 在应用程序上颤振“演示”树桩
- sql - 在下面的代码中,如果最后一个查询没有返回reject_count(因为表中没有拒绝),那么这个查询下面的语句没有执行
- algorithm - O(mn) 比 O((m+n)^2) 好吗?