Hello. There is a class inherited from LinearLayout, in which among other elements there is an ImageView. ImageView is specified as VectorAsset. It is necessary after a certain user action to change the color ImageView. Tell me how you can do this (Change color). ps I did not find the setColor method.

    1 answer 1

    There is another method for ImageView :

     imageView.setColorFilter(ContextCompat.getColor(context,R.color.colorAccent)); 

    Another variant:

     DrawableCompat.setTint(imageView.getDrawable(), ContextCompat.getColor(context, R.color.colorAccent)); 
    • The first thing I tried it, but the color of the image has not changed. - Nikita
    • @Nikita In the sense of "color image"? Need to replace the picture with a color or do you want to put a mask on top? - Vladimir Parfenov
    • @Nikita Well, it would be nice if you added this to the question. And so try to specify the second parameter is one of the blend modes. For example, PorterDuff.Mode.MULTIPLY or PorterDuff.Mode.OVERLAY , depending on what effect you want to get. - eugeneek
    • I clarify that there is an icon in the form of vectorAsset in gray, after some user action, this icon should turn green. I tried to specify the MULTIPLY and OVERLAY modes, nothing helped - Nikita
    • Added another option. - eugeneek