繁体   English   中英

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

[英]How to tint vector drawable inside FAB? (android:tint does not seem to work)

出于某种原因, 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"/>  

矢量可绘制

<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 属性(我不想这样做)。

请指教。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM