android - 嵌套 ScrollView 中的 ESRI map

标签 android android-nestedscrollview esri-maps arcgis-android-api

我正在尝试将 ESRI map 添加到我位于 NestedScrollView 中的 fragment 。它加载正常,但是当我移动 map 时,如果我删除 NestedScrollView,它不会顺利移动,一切正常。

这是我在 NestedScrollView 中的 ESRI map View

<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 的 map View 喜欢:

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
    }

}

还是一样的问题, map 移动不流畅。

最佳答案

它将禁止 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)
}

关于android - 嵌套 ScrollView 中的 ESRI map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53850779/

相关文章:

javascript - 使用 Statistics Definition() 计算多个字段中的总和

android - 谷歌浏览器无法在 Android 上的 Deep Link 上打开应用程序

安卓 EditText 提示

c# - 使用 Xamarin Forms 播放视频

android - Opengl Es 线宽

android - 将 Android NestedScrollView 水平滑动传递给父 View

javascript - IBEX 仪表板 map 在成功构建后中断

android - 按钮隐藏在带有折叠工具栏的嵌套 ScrollView 中

android - NestedScrollView 的 smoothScrollTo() 行为怪异

javascript - 如何在 ArcGIS Esri Map 中自动显示位置的放大 View ?