I've been looking through a bunch of the different topics about issues with the ScrollView stealing the touch events from a MapView with google maps and I've seen several different solutions on how to override the onTouch event. I am using ArcGIS maps for my app and I have tried several of the google map solutions and nothing has worked. So I'm wondering if anyone out there might have a solution that would work with the ArcGIS mapview in a ScrollView to override the onTouch event so that the map can be panned both vertically and horizontally.
Currently I only have the MapView with a couple of layers added to it, so it's a very basic setup, but if posting some of the code will help I'll be more than happy to post some of the code.
Came up with a solution that works.
I put the listener in the onCreate for the activity.
MyTouchListener tl = new MyTouchListener(this, mMapView);
mMapView.setOnTouchListener(tl);
Then I created a class within the same activity that extends the MapOnTouchListener class.
class MyTouchListener extends MapOnTouchListener{
ScrollView sv;
public MyTouchListener(Context c, MapView m){
super(c, m);
}
public boolean onTouch(View v, MotionEvent event){
sv = (ScrollView) findViewById(R.id.scroll);
int action = event.getAction();
switch(action){
case MotionEvent.ACTION_DOWN:
// will disable the scrollview from being able to
// intercept the touch events for the mapview
sv.requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// gives control back over to the scrollview
sv.requestDisallowInterceptTouchEvent(false);
break;
}
super.onTouch(v, event);
return true;
}
}
I hope this will help someone out and save them the hours I spent trying to find what I was looking for.