更改矢量资源的“填充颜色”不起作用

时间:2017-08-15 00:58:54

标签: android

我通过Android studio None创建了一个矢量资源资源,图标正确显示没有问题。 但是当我更改Vector Asset属性时,根本没有任何变化,图标会保留其默认选定颜色和未选定颜色。 这是我的矢量xml:

fill color

<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportHeight="51.0" android:viewportWidth="61.0"> <path android:fillColor="@color/unselected" android:pathData="M59.28,1.7a5.67,5.67 0,0 0,-4.14 -1.71L5.86,-0.01a5.67,5.67 0,0 0,-4.14 1.71A5.54,5.54 0,0 0,0 5.79v39.42a5.54,5.54 0,0 0,1.72 4.09,5.67 5.67,0 0,0 4.14,1.71L55.14,51.01a5.67,5.67 0,0 0,4.14 -1.71A5.54,5.54 0,0 0,61 45.21v-39.42A5.54,5.54 0,0 0,59.28 1.7ZM18.77,45.21a1.12,1.12 0,0 1,-0.33 0.83,1.14 1.14,0 0,1 -0.84,0.33L5.86,46.37a1.14,1.14 0,0 1,-0.84 -0.33,1.12 1.12,0 0,1 -0.33,-0.83v-6.96a1.12,1.12 0,0 1,0.33 -0.83,1.14 1.14,0 0,1 0.84,-0.33L17.6,37.09a1.14,1.14 0,0 1,0.84 0.33,1.12 1.12,0 0,1 0.33,0.83v6.96ZM18.77,31.3a1.13,1.13 0,0 1,-1.17 1.16L5.86,32.46a1.14,1.14 0,0 1,-0.84 -0.33,1.13 1.13,0 0,1 -0.33,-0.83v-6.96a1.1,1.1 0,0 1,0.33 -0.83,1.14 1.14,0 0,1 0.84,-0.33L17.6,23.18a1.14,1.14 0,0 1,0.84 0.33,1.1 1.1,0 0,1 0.33,0.83v6.96ZM18.77,17.38a1.14,1.14 0,0 1,-0.33 0.84,1.17 1.17,0 0,1 -0.84,0.32L5.86,18.54a1.18,1.18 0,0 1,-0.84 -0.32,1.14 1.14,0 0,1 -0.33,-0.84v-6.95a1.14,1.14 0,0 1,0.33 -0.84,1.18 1.18,0 0,1 0.84,-0.32L17.6,9.27a1.17,1.17 0,0 1,0.84 0.32,1.14 1.14,0 0,1 0.33,0.84v6.95ZM37.54,45.21a1.12,1.12 0,0 1,-0.33 0.83,1.14 1.14,0 0,1 -0.84,0.33L24.63,46.37a1.14,1.14 0,0 1,-0.84 -0.33,1.12 1.12,0 0,1 -0.33,-0.83v-6.96a1.12,1.12 0,0 1,0.33 -0.83,1.14 1.14,0 0,1 0.84,-0.33L36.37,37.09a1.14,1.14 0,0 1,0.84 0.33,1.12 1.12,0 0,1 0.33,0.83v6.96h0ZM37.54,31.3a1.13,1.13 0,0 1,-1.17 1.16L24.63,32.46a1.14,1.14 0,0 1,-0.84 -0.33,1.13 1.13,0 0,1 -0.33,-0.83v-6.96a1.1,1.1 0,0 1,0.33 -0.83,1.14 1.14,0 0,1 0.84,-0.33L36.37,23.18a1.14,1.14 0,0 1,0.84 0.33,1.1 1.1,0 0,1 0.33,0.83v6.96h0ZM37.54,17.38a1.14,1.14 0,0 1,-0.33 0.84,1.17 1.17,0 0,1 -0.84,0.32L24.63,18.54a1.18,1.18 0,0 1,-0.84 -0.32,1.14 1.14,0 0,1 -0.33,-0.84v-6.95a1.14,1.14 0,0 1,0.33 -0.84,1.18 1.18,0 0,1 0.84,-0.32L36.37,9.27a1.17,1.17 0,0 1,0.84 0.32,1.14 1.14,0 0,1 0.33,0.84v6.95h0ZM56.31,45.21a1.12,1.12 0,0 1,-0.33 0.83,1.14 1.14,0 0,1 -0.84,0.33L43.4,46.37a1.14,1.14 0,0 1,-0.84 -0.33,1.12 1.12,0 0,1 -0.33,-0.83v-6.96a1.12,1.12 0,0 1,0.33 -0.83,1.14 1.14,0 0,1 0.84,-0.33L55.14,37.09a1.14,1.14 0,0 1,0.84 0.33,1.12 1.12,0 0,1 0.33,0.83v6.96ZM56.31,31.3a1.13,1.13 0,0 1,-0.33 0.83,1.14 1.14,0 0,1 -0.84,0.33L43.4,32.46a1.13,1.13 0,0 1,-1.17 -1.16v-6.96a1.1,1.1 0,0 1,0.33 -0.83,1.14 1.14,0 0,1 0.84,-0.33L55.14,23.18a1.14,1.14 0,0 1,0.84 0.33,1.1 1.1,0 0,1 0.33,0.83v6.96ZM56.31,17.38a1.14,1.14 0,0 1,-0.33 0.84,1.18 1.18,0 0,1 -0.84,0.32L43.4,18.54a1.17,1.17 0,0 1,-0.84 -0.32,1.14 1.14,0 0,1 -0.33,-0.84v-6.95a1.14,1.14 0,0 1,0.33 -0.84,1.17 1.17,0 0,1 0.84,-0.32L55.14,9.27a1.18,1.18 0,0 1,0.84 0.32,1.14 1.14,0 0,1 0.33,0.84v6.95Z" /> </vector> 不起作用,图标保持默认@color/unselected

我在BottomNavigation Layout中使用这些向量,它会导航导航菜单xml文件,如下所示:

#FF000000

我尝试了tint属性,但没有改变......

2 个答案:

答案 0 :(得分:1)

尝试在布局XML中的'Bottom NavigationView'定义中设置'app:itemIconTint =“@ color / yourColor”'属性。就我而言,我在NavigationView中遇到了类似的问题。这就是我修复它的方法:

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    app:itemIconTint="@color/scrollbarColor" />

希望有所帮助。

答案 1 :(得分:0)

我删除了元素附带的以下属性:

android:tint="?attr/colorControlNormal"

之后,元素的以下属性开始正常工作。

android:fillColor="#830E0E"