I crated a Vector asset using Android studio and I have the following code:
<vector android:height="24dp" android:tint="#4CAC78"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M23,12l-2.44,-2.78 0.34,-3.68 -3.61,-0.82 -1.89,-3.18L12,3 8.6,1.54 6.71,4.72l-3.61,0.81 0.34,3.68L1,12l2.44,2.78 -0.34,3.69 3.61,0.82 1.89,3.18L12,21l3.4,1.46 1.89,-3.18 3.61,-0.82 -0.34,-3.68L23,12zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z"/>
</vector>
The result looks like this:
The problem is that the exclamation mark is transparent and I would like to make it non-transparent. I tried to change the attribute path android:fillColor="@android:color/black
but this did not have any effect. Any idea how I can do this?
CodePudding user response:
The green area and the exclamation mark are really created by two separate paths that are combined into the single path
statement in the vector drawable. To color them separately, you need to separate them out into separate path statements:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#4CAC78"
android:pathData="M23,12l-2.44,-2.78 0.34,-3.68 -3.61,-0.82 -1.89,-3.18L12,3 8.6,1.54 6.71,4.72l-3.61,0.81 0.34,3.68L1,12l2.44,2.78 -0.34,3.69 3.61,0.82 1.89,3.18L12,21l3.4,1.46 1.89,-3.18 3.61,-0.82 -0.34,-3.68L23,12z" />
<path
android:fillColor="@android:color/black"
android:pathData="M13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z" />
</vector>