You can create a custom root layout that spies on touch events descending to a map fragment and use it instead of the standard one FrameLayout:
public class CustomFrameLayout extends FrameLayout {
private GestureDetector gestureDetector;
private IDragCallback dragListener;
public CustomFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
gestureDetector = new GestureDetector(context, new GestureListener());
}
public interface IDragCallback {
void onDrag();
}
public void setOnDragListener(IDragCallback listener) {
this.dragListener = listener;
}
@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) {
if(dragListener != null) {
dragListener.onDrag();
}
return false;
}
}
}
========== your_activity_layout.xml:
<com.your.package.CustomFrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/checkpoint"
android:id="@+id/map"/>
========= YourActivity.java
CustomFrameLayout mapRoot = (CustomFrameLayout) findViewById(R.id.map);
mapRoot.setOnDragListener(this);
.......
@Override
public void onDrag() {
}
:
, android:name="com.google.android.gms.maps.SupportMapFragment" FrameLayout . ? android:name <fragment> xml. .