【问题标题】:Android : How to add animated marker [duplicate]Android:如何添加动画标记[重复]
【发布时间】:2013-12-07 14:36:30
【问题描述】:

请有人帮我添加像 one 这样的动画标记,用于 android google maps V2

谢谢。

【问题讨论】:

  • 由于那里没有明显的“动画标记”,也许您可​​以进一步解释一下该术语的含义。
  • 我想在示例中添加这种类型的标记(.gif 标记)
  • 嗨,我也面临同样的问题,如果你有解决方案,请在这里分享解决方案。谢谢

标签: android google-maps-markers google-maps-api-2


【解决方案1】:

也许你会想到研究它......

TranslateAnimation 动画 = new TranslateAnimation(0.0f, 400.0f,0.0f, 0.0f);
//new TranslateAnimation(xFrom,xTo, yFrom,yTo)

animation.setDuration(2000);  // animation duration 
animation.setRepeatCount(100);  // animation repeat count (total repetition)
animation.setRepeatMode(2);   // repeat animation (left to right, right to left )
//animation.setFillAfter(true);      

img_animation.startAnimation(animation);

【讨论】:

    【解决方案2】:

    请使用以下代码从可绘制对象中设置标记

           BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.current_position_tennis_ball)
    
    
            MarkerOptions markerOptions = new MarkerOptions().position(latLng)
                     .title("Current Location")
                     .snippet("Thinking of finding some thing...")
                     .icon(icon);
    
            mMarker = googleMap.addMarker(markerOptions);
    

    【讨论】:

    • 请随意解释这将如何实现任何类型的动画效果。
    • @CommonsWare 为什么你认为这行不通?我没有尝试过 Prakash 解决方案,但理论上你可以将它链接到可绘制的 xml,该 xml 有一组图像每 200 毫秒显示一次。这不会为图像设置动画吗?
    • @Snake:您假设 BitmapDescriptor 能够处理动画,而我假设它不是(如果是,他们会命名为 DrawableDescriptor 而不是 @987654324 @)。这就是为什么我建议回答者需要解释的原因。
    • 哦,好点。我想我会尝试一下,找出适用的理论。虽然你的回答让我失去了希望,因为我正在寻找一种动画标记的方法
    • @CommonsWare。你赢了! (我对大声笑的方式并不感到惊讶)。我试过了,它在谷歌库中出现空指针崩溃。真的很烦人,您无法以更简单的方式为标记设置动画。除非我错过了它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多