【发布时间】:2015-09-23 04:19:24
【问题描述】:
我想在用户点击谷歌地图信息窗口时显示幻灯片动画。
我的动画工作正常,显示和消失,但是当我点击消失时,谷歌地图冻结并且不再工作,但应用程序没有强制关闭,菜单仍然有效。如果我单击菜单,转到另一个活动然后返回,地图将再次运行,如果我单击信息窗口以显示动画再次冻结。
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>
编辑: xml来调用动画。
<?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>
动画。
向下滑动
<?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>
向上滑动
<?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>
任何帮助都是不胜感激的。
谢谢
【问题讨论】:
-
一般来说,似乎在 infowindow 上使用动画或附加视图可能会导致滞后。这是一个相关的问题。希望这能给你一些想法:link
-
这个动画不是信息窗口...当用户从谷歌地图点击信息窗口时会出现动画...当点击信息窗口时,它会调用另一个带有线性布局的xml(看看我的代码已编辑)...问题是关闭此线性布局时 googlemap 冻结
-
你解决了这个问题吗?
-
我解决了这个问题
标签: android google-maps animation infowindow