您必须创建自定义 MapView。按照下面提供的代码片段
public class AppMapView extends MapView {
public AppMapView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_UP:
System.out.println("unlocked");
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
case MotionEvent.ACTION_DOWN:
System.out.println("locked");
this.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
return super.dispatchTouchEvent(ev);
}
}
在 XML 中遵循以下代码:
<com.tech.linez.brixlanepassenger.custom_views.AppMapView
android:id="@+id/map_ride_route"
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_margin="10dp"/>