Android 可作为贴图标记绘制的动画矢量

Android 可作为贴图标记绘制的动画矢量,android,google-maps-markers,google-maps-android-api-2,Android,Google Maps Markers,Google Maps Android Api 2,我想在Android中使用animatedVectorDrawable作为地图标记。有没有办法做到这一点。 我尝试的是,我使用BitmapDescriptorFactory类将VectorDrawable转换为位图,效果很好,但当我转到转换AnimatedVectorDrawable时,它在地图上什么都没有显示 下面是我迄今为止尝试的代码 你不能那样做。为了将图像添加到地图作为标记,您需要位图(最好是png)。 您可以做的是将矢量转换为位图,然后重试。不,您不能这样做。其他任何方法都无法做到这一

我想在Android中使用
animatedVectorDrawable
作为地图标记。有没有办法做到这一点。 我尝试的是,我使用
BitmapDescriptorFactory
类将
VectorDrawable
转换为位图,效果很好,但当我转到转换
AnimatedVectorDrawable
时,它在地图上什么都没有显示

下面是我迄今为止尝试的代码


你不能那样做。为了将图像添加到地图作为标记,您需要位图(最好是png)。
您可以做的是将矢量转换为位图,然后重试。

不,您不能这样做。其他任何方法都无法做到这一点。对不起,不,没有其他方法已确认,不能对地图组件使用常规的
视图
动画。本演练旨在运行
值Animator
,不断更新组件的属性,如alpha、半径或颜色。我理解,谢谢您的回答
   .
   .
   .
    MarkerOptions marker1 = new MarkerOptions();
    marker1.icon( getBitmapDescriptor(R.drawable.setpickuplocationdrawable));
    marker1.position(pickuplatlng);
    marker1.title("Marker at place1");
    googleMap.addMarker(marker1);
  }




private BitmapDescriptor getBitmapDescriptor(int id) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        AnimatedVectorDrawable vectorDrawable = (AnimatedVectorDrawable) getDrawable(id);

        int h = vectorDrawable.getIntrinsicHeight();
        int w = vectorDrawable.getIntrinsicWidth();

        vectorDrawable.setBounds(0, 0, w, h);

        Bitmap bm = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bm);
        vectorDrawable.draw(canvas);

        return BitmapDescriptorFactory.fromBitmap(bm);

    } else {
        return BitmapDescriptorFactory.fromResource(id);
    }
}