Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set vector icon asset's tint in jetpack compose?

I used jetpack compose, imported a vector icon from Resource Manager (View->Tool Windows->Resource Manager) and got the following XML code.

But I got an error of ?attr/colorControlNormal saying "not found".

Could some one tell me how to fix please? Thanks.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:tint="?attr/colorControlNormal">
  <path
    android:fillColor="@android:color/white"
    android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
like image 424
caibirdcnb Avatar asked Sep 16 '25 00:09

caibirdcnb


1 Answers

You need to change ?attr/colorControlNormal to ?android:colorControlNormal

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:tint="?android:colorControlNormal">
  <path
    android:fillColor="@android:color/white"
    android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
like image 129
Barret Vogtman Avatar answered Sep 18 '25 17:09

Barret Vogtman