I want to show a slide animation when user click in the google map info window.
My animation is work correclty, showing and dissapearing, but when i click to dissapear, the google map freezes and dont work anymore, but the app dont get a force close, and the menu still work. if i click in the menu, go to another activity and then get back, the map works again,if i click on info window to show the animation its freeze again.
googlemap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(final Marker marker) {
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slidedown);
layoutToAdd.addView(view);
view.startAnimation(animation1);
Toast.makeText(getBaseContext(), "animation opened", Toast.LENGTH_LONG).show();
if ( view != null) {
layoutToAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (view.isShown()) {
Animation animation1 = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slideup);
view.startAnimation(animation1);
((LinearLayout) view.getParent()).removeView(view);
Toast.makeText(getBaseContext(), "animation closed", Toast.LENGTH_LONG).show();
}
}
});
}
}
});
}
xml
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class= "com.google.android.gms.maps.SupportMapFragment"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainlo"
tools:context=".MainActivity">
</LinearLayout>
</fragment>
<!-- Side navigation drawer UI -->
<ListView
android:id="@+id/navList"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="#ffeeeeee"/>
</android.support.v4.widget.DrawerLayout>
EDIT: xml to call the animation.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/lay">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#000000"
android:layout_gravity="bottom">
<TextView
android:id="@+id/mytext"
android:text="You inflated me..i added to u r layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
The animation.
Slide Down
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
Slide Up
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true" >
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/linear_interpolator"
android:toXScale="1.0"
android:toYScale="0.0" />
</set>
any help is apreciate.
Thanks
https://developers.google.com/maps/documentation/android-api/infowindows