代码之家  ›  专栏  ›  技术社区  ›  Andrea deCandia

设置不带主题的属性值引用

  •  1
  • Andrea deCandia  · 技术社区  · 6 年前

    我想在不更改应用程序或活动主题的情况下,将值资源引用设置为样式。

    向量.xml

    <vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:height="24dp", android:width="24dp"
        android:viewportWidth="24", android:viewportHeight="24">
        <path android:fillColor="?mycolor" android:pathData="8,L5,5L8,1" />
    </vector>
    

    属性.xml

    <resources>
        <attr name="mycolor" format="reference" />
    </resources>
    

    样式.xml

    <style name="colorscheme">
            <item name="myColor">@color/red</item>
    </style>
    

    换言之,我该如何将dravable fillcolor设置为@color/red?

    0 回复  |  直到 6 年前