Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Hi i am trying to set a fillcolour to use the theme/style of colorOnPrimary

via android:fillColor="?colorOnPrimary"

However i get this error: Invalid color value ?colorOnPrimary when i try and build my project

This is what my vector asset xml looks like:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="18dp"
    android:height="18dp"
    android:viewportWidth="18"
    android:viewportHeight="18">
    <path
        android:fillColor="?colorOnPrimary"
        android:fillType="evenOdd"
        android:pathData="...." />
</vector>
question from:https://stackoverflow.com/questions/66047463/use-style-theme-colour-on-a-vector-asset

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
382 views
Welcome To Ask or Share your Answers For Others

1 Answer

For color use color-resources with @color, you might have colorPrimary in colors.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="18dp"
    android:height="18dp"
    android:viewportWidth="18"
    android:viewportHeight="18">
    <path
        android:fillColor="@color/colorOnPrimary"
        android:fillType="evenOdd"
        android:pathData="...." />
</vector>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...