如何在FAB内部着色矢量? (android:tint似乎不起作用)

问题描述 投票:0回答:1

由于某种原因,android:tint XML属性实际上不会为我的矢量drawable着色。

FAB布局

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="end|bottom"
    android:layout_margin="16dp"
    android:tint="@android:color/holo_blue_light"
    android:src="@drawable/ic_favourite_empty"
    app:rippleColor="?colorSecondaryVariantLight"/>  

矢量drawable

<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:width="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">

<path
    android:fillColor="#000000"
    android:pathData="M19.66 3.99c-2.64-1.8-5.9-.96-7.66 1.1-1.76-2.06-5.02-2.91-7.66-1.1-1.4.96-2.28 2.58-2.34 4.29-.14 3.88 3.3 6.99 8.55 11.76l.1.09c.76.69 1.93.69 2.69-.01l.11-.1c5.25-4.76 8.68-7.87 8.55-11.75-.06-1.7-.94-3.32-2.34-4.28zM12.1 18.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05z"/>

如果我删除fillColor图标将根本不可见,如果我将其更改为其他颜色,它仍然保持黑色。我可以改变其颜色的唯一方法是更改​​我的应用主题中的colorOnSecondary XML属性(我不想这样做)。

请指教。

floating-action-button android-vectordrawable tint android-graphics
1个回答
0
投票

如果有人需要,我找到了解决方案:使用app:tint而不是android:tint。 干杯。

© www.soinside.com 2019 - 2024. All rights reserved.