h4l*_*c0n 2 java animation android google-maps google-api
我正在尝试在我的Android应用中使用自定义标记"气泡".为此,我创建了一个InfoWindowAdapter,它返回并填充View.
但是,出于某种原因,它似乎不允许我将动画应用于该视图(或内部的任何内容).我希望它以某种动画的方式弹出,但我可能会遗漏一些东西.
这是我到目前为止所尝试的:
map.setInfoWindowAdapter(new InfoWindowAdapter() {
private final View contents = getLayoutInflater().inflate(R.layout.marker_layout, null);
public View getInfoWindow(Marker marker) {
TranslateAnimation animator = new TranslateAnimation(0.0f, 0.0f, 0.0f, 100.0f);
animator.setDuration(2000);
animator.setInterpolator(new AccelerateInterpolator());
animator.setFillAfter(true);
contents.findViewById(R.id.entity_name).clearAnimation();
contents.findViewById(R.id.entity_name).startAnimation(animator);
((TextView) contents.findViewById(R.id.entity_name)).setText(marker.getTitle());
return contents;
}
/* ... */
Run Code Online (Sandbox Code Playgroud)
视图成功创建并填充,但没有明显的动画.如果我将相同的动画应用到布局的另一个元素,它可以完美地工作,所以我开始认为这是谷歌地图使用信息窗口的方式,也许呢?
您无法将动画应用于InfoWindow,原因很简单.你在里面看到的InfoWindow不是你定义的布局,而是从中绘制的图像.意思是你无法操纵这个InfoWindow.
来自Google的文档:
注意:绘制的信息窗口不是实时视图.视图在返回时呈现为图像(使用
View.draw(Canvas)).这意味着对视图的任何后续更改都不会被地图上的信息窗口反映出来.要稍后更新信息窗口(例如,在图像加载后),请致电showInfoWindow().此外,信息窗口将不会考虑正常视图(例如触摸或手势事件)的任何典型交互.但是,您可以在整个信息窗口中收听通用点击事件,如下节所述.
| 归档时间: |
|
| 查看次数: |
3170 次 |
| 最近记录: |