Androidtint属性无效,不改变颜色

    技术2023-05-24  69

    注意是否在vector里设置了 android:fillType="evenOdd",有的话把它删掉

     

    有问题的代码: 

    <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="12dp" android:height="11dp" android:viewportWidth="12" android:viewportHeight="11"> <path android:fillColor="#00000000" android:fillType="evenOdd" android:pathData="M1.2696,1.6109L10.159,9.3891" android:strokeWidth="2" android:strokeColor="#FF3B30" android:strokeLineCap="round" /> <path android:fillColor="#00000000" android:fillType="evenOdd" android:pathData="M10.159,1.6109L1.2696,9.3891" android:strokeWidth="2" android:strokeColor="#FF3B30" android:strokeLineCap="round" /> </vector>

     

    好用的代码:

    <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="13dp" android:height="13dp" android:viewportWidth="13" android:viewportHeight="13" android:tint="?android:colorPrimary"> <path android:fillColor="#FF000000" android:pathData="M1.2917,6.5L11.8333,6.5" android:strokeWidth="2" android:strokeColor="#FF000000" android:strokeLineCap="round" /> <path android:fillColor="#FF000000" android:pathData="M6.5625,1L6.5625,12" android:strokeWidth="2" android:strokeColor="#FF000000" android:strokeLineCap="round" /> </vector>

     

     

    Processed: 0.010, SQL: 9