Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have implemented some other solution to solve this problem. What I did - is I placed my GoogleMap inside custom RelativeLayout. After that <code>onInterceptTouchEvent</code> callback works like a charm and underlying map receives touch events as expected</p> <p>here is my xml:</p> <pre><code>&lt;com.my.package.name.map.MapRelativeLayout android:id="@+id/map_root_layout" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment"/&gt; &lt;/com.my.package.name.map.MapRelativeLayout&gt; </code></pre> <p>And custom relative layout:</p> <pre><code>package com.my.package.name.map; import android.content.Context; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; import android.widget.RelativeLayout; public class MapRelativeLayout extends RelativeLayout { private GestureDetector gestureDetector; public MapRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); gestureDetector = new GestureDetector(context, new GestureListener()); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { gestureDetector.onTouchEvent(ev); return false; } private class GestureListener extends GestureDetector.SimpleOnGestureListener { @Override public boolean onDown(MotionEvent e) { return true; } @Override public boolean onDoubleTap(MotionEvent e) { return false; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { //do whatever you want here return false; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload