0

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

halfer
  • 19,471
  • 17
  • 87
  • 173
MJakhongir
  • 535
  • 1
  • 8
  • 23
  • Answering my own question... this answer worked !! https://stackoverflow.com/questions/16974983/google-maps-api-v2-supportmapfragment-inside-scrollview-users-cannot-scroll-th – MJakhongir Nov 13 '17 at 13:27

2 Answers2

1

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;
        }
    });
1

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);
   }
}
Hantash Nadeem
  • 418
  • 6
  • 9