1

I would like to animate a View containing a Map using the Google Map API.

For animation, I have taken the code of DropDownAnim from here : Android: Expand/collapse animation.

For the code of Maps implementation, I have taken the code from the maps official : Google Maps API : Verify Map availability.

If I change the setUpMap() method like this (so it will animate on the start of the activity), everything works well :

private void setUpMap() {
    mMap.addMarker(new MarkerOptions().position(new LatLng(48.8407258, 2.2448904)).title("Marker"));
    mMap.setMyLocationEnabled(true);

    DropDownAnim a = new DropDownAnim(mapLayout, 800, true);
    a.setDuration(500);
    mapLayout.setAnimation(a);
    mapLayout.animate();
}

But, if I try to do the animation when clicking on the Map, the animation never starts (and the onClick is called because I have added a Log in the constructor of the animation, but applyTransformation is never called) :

private void setUpMap() {
    mMap.addMarker(new MarkerOptions().position(new LatLng(48.8407258, 2.2448904)).title("Marker"));
    mMap.setMyLocationEnabled(true);

    mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {

        @Override
        public void onMapClick(LatLng point) {
            DropDownAnim a = new DropDownAnim(mapLayout, 800, true);
            a.setDuration(500);
            mapLayout.setAnimation(a);
            mapLayout.animate();
        }
    });
}

There's no error in LogCat, the only thing that occurs is that the animation never starts.

May you know what I did wrong ?

Community
  • 1
  • 1

1 Answers1

0

I found the solution, the solution is to replace :

mapLayout.setAnimation(a);
mapLayout.animate();

by :

mapLayout.startAnimation(a);