The mapview only scrolls sideways, as if you try to scroll vertically the ScrollView is taking the action. I've tried requestDisallowInterceptTouchEvent(true); but it didn't help.
PS. Yandex MapView extends RelativeLayout
The mapview only scrolls sideways, as if you try to scroll vertically the ScrollView is taking the action. I've tried requestDisallowInterceptTouchEvent(true); but it didn't help.
PS. Yandex MapView extends RelativeLayout
Try use the MapView onTouchEvent like below
public boolean onTouchEvent(MotionEvent ev) {
int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
this.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
// Handle MapView's touch events.
super.onTouchEvent(ev);
return true;
}
requestDisallowInterceptTouchEvent if you set this true you can scroll nested view if it is false the parent ScrollView scroll is enabled.
For ListView we don't need this Event Listener simply listview.setNestedScrollingEnabled(true);
mapview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
this.getParent().requestDisallowInterceptTouchEvent(true);
break;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
super.onTouchEvent(ev);
return true;
}
});
You have to create custom MapView. Follow the code snippet provided below
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);
}
}