我正在尝试创建一个看起来像这样的自定义标记:
我有看起来像这样的 XML 可绘制对象:
<solid
android:color="#0093e8"/>
<size
android:width="120dp"
android:height="120dp"/>
是否可以为标记添加“波浪效果”并且波浪逐渐淡出(如图所示)?此外,此动画应不断播放(无需用户点击 map 标记)我该怎么办?
最佳答案
我做了一些非常相似的事情,但我使用了 GroundOverlay 而不是标记,首先我定义了我的自定义动画:
public class RadiusAnimation extends Animation {
private GroundOverlay groundOverlay;
public RadiusAnimation(GroundOverlay groundOverlay) {
this.groundOverlay = groundOverlay;
}
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
groundOverlay.setDimensions( (100 * interpolatedTime) );
groundOverlay.setTransparency( interpolatedTime );
}
@Override
public void initialize(int width, int height, int parentWidth,int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
}
}
然后我在 groundOverlay 上运行动画,在 onMapReady 之后:
...
groundOverlay = mGoogleMap.addGroundOverlay(new GroundOverlayOptions()
.image(image)
.position(new LatLng(lat, lng), 100));
groundAnimation = new RadiusAnimation(groundOverlay);
groundAnimation.setRepeatCount(Animation.INFINITE);
groundAnimation.setRepeatMode(Animation.RESTART);
groundAnimation.setDuration(2000);
mapView.startAnimation(groundAnimation); // MapView where i show my map
...
希望对你有帮助
关于android - Google Maps API 中的动画 map 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38306777/