My Themes color attributes do not work in Android Vector Drawables.
Providing two examples below:
android:fillColor
declared with an @color
<!-- More vector source here -->
<path
android:pathData="M2.736,0L20.056,0A2.736,2.736 0,0 1,22.792 2.736L22.792,30.422A2.736,2.736 0,0 1,20.056 33.158L2.736,33.158A2.736,2.736 0,0 1,0 30.422L0,2.736A2.736,2.736 0,0 1,2.736 0z"
android:strokeWidth="0.264583"
android:fillColor="@color/blue_500"/>
<!-- More vector source here -->
Preview in Android Studio:
In app:
As you can notice the Vector Drawable displays correctly.
android:fillColor
declared with an ?attr
<!-- More vector source here -->
<path
android:pathData="M2.736,0L20.056,0A2.736,2.736 0,0 1,22.792 2.736L22.792,30.422A2.736,2.736 0,0 1,20.056 33.158L2.736,33.158A2.736,2.736 0,0 1,0 30.422L0,2.736A2.736,2.736 0,0 1,2.736 0z"
android:strokeWidth="0.264583"
android:fillColor="?attr/colorTertiary"/>
<!-- More vector source here -->
Preview in Android Studio:
In app:
As you can notice the expected tertiary color is transparent and shows a view below it (Range Slider track if that is of any help)
I have read:
- Theme attributes not working correctly with VectorDrawable
- Android Studio 4.1: theme attributes in vector drawables cause java.lang.IllegalArgumentException
- https://medium.com/makingtuenti/managing-your-android-app-iconography-a2f4aa9cb49d
None of these posts were helpful in resolution of this issue.
What can I do to resolve this unexpected behavior?