我正在android上使用google map,现在我正在使用AnimatedVectorDrawable为图像创建效果,但是我不知道如何将其变成标记。可以做到吗,否则如何为标记添加效果?
创建AnimatedVectorDrawable
private fun m():Drawable{
val drawable : Drawable? = ContextCompat.getDrawable(this,R.drawable.radar_inactive2)
radar_inactive.setImageDrawable(drawable)
radar_inactive.visibility = View.VISIBLE
animation = radar_inactive.drawable as AnimatedVectorDrawable
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
animation!!.registerAnimationCallback(object: Animatable2.AnimationCallback() {
override fun onAnimationEnd(drawable: Drawable?) {
animation?.start()
}
})
}
return drawable!!
}
在地图中添加
val canvas = Canvas()
val bitmap = Bitmap.createBitmap(m().getIntrinsicWidth(), m().getIntrinsicHeight(), Bitmap.Config.ARGB_8888)
canvas.setBitmap(bitmap)
m().draw(canvas)
val bd = BitmapDescriptorFactory.fromBitmap(bitmap)
mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney").icon(BitmapDescriptorFactory.fromBitmap(bitmap)))