Is there a performance impact on the color change of vector drawings programmatically?

I use a vector that can be done in my code. Based on some state, I need to change the color of the paint. Using the code below to achieve it.

Drawable drawable = VectorDrawableCompat.create(context.getResources(), 
                        R.drawable.icon_vector_star, null);
    if(drawable != null) {
        drawable = drawable.mutate();
        drawable = DrawableCompat.wrap(drawable);
        //Change the tint to grey to mark it disabled.
        DrawableCompat.setTint(drawable, 
              ContextCompat.getColor(context, R.color.grey));
        DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
        imageView.setImageDrawable(drawable);
    } else {
        Log.e(LOG_TAG, "Error while creating vector drawable");
    }

Is there any performance impact in doing so? Should I use a different vector can I make a different color and just set it? Please suggest.

+4
source share

Source: https://habr.com/ru/post/1675750/


All Articles