Search code examples
javaandroidtouchandroid-animationgoogle-maps-android-api-2

How to disable touch detection while Google Map animation is running in android


When I use the method below to execute an animation on google map, the animation ends if we touch the screen while animation is executing.

googleMap.animateCamera(
                        CameraUpdateFactory.newCameraPosition(cameraPosition1),400,
                        new CancelableCallback() {

                              @Override
                              public void onFinish() {
                              }

                              @Override
                              public void onCancel() {
                              }
        });

I have tried disabling the touch detection using the code below

mapFragment.getView().setEnabled(false); 

googleMap.getUiSettings().setAllGesturesEnabled(false);

but the application detects touch despite the above lines. How do you correctly disable touch?


Solution

  • Don't use setEnabled(false) for the view instead use setClickable(false)

    mapFragment.getView().setClickable(false);

    This should work.

    EDIT

    Apparently this is bug filed here

    https://code.google.com/p/gmaps-api-issues/issues/detail?id=5114

    as a work around you can deploy a transparent layer which will receive touch events instead of MapFragment .