Cannot set tint programmatically in vector drawable

Viewed 56

I'm using SDK 28 to compile this app.

This is the vector xml that I'm using:

<vector android:height="10dp" android:tint="#FFFFFF"
    android:viewportHeight="22" android:viewportWidth="36"
    android:width="14dp"  xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:translateX="13" >
        <path android:fillColor="@android:color/white" android:pathData="M19,15l-1.41,-1.41L13,18.17V2H11v16.17l-4.59,-4.59L5,15l7,7L19,15z"/>
    </group>
</vector>

My question is: how do I change tint programmatically? I have tried solutions I have found on StackOverFlow, but none work.

1 Answers

To set the tint use this code:

ImageViewCompat.setImageTintList(imageView, ColorStateList.valueOf(ContextCompat.getColor(context, R.color.your_color)));
Related