Android:
5.0.0
We have limited support to only using Bitmaps,
though you can convert any drawable to an Icon using the following utility method:
public class IconUtils {
/**
* Demonstrates converting any Drawable to an Icon, for use as a marker icon.
*/
public static Icon drawableToIcon(@NonNull Context context, @DrawableRes int id, @ColorInt int colorRes) {
Drawable vectorDrawable = ResourcesCompat.getDrawable(context.getResources(), id, context.getTheme());
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
DrawableCompat.setTint(vectorDrawable, colorRes);
vectorDrawable.draw(canvas);
return IconFactory.getInstance(context).fromBitmap(bitmap);
}
}
Refs #7897
Most helpful comment
We have limited support to only using Bitmaps,
though you can convert any drawable to an Icon using the following utility method:
Refs #7897