在材料1.1.0中具有可在FAB中绘制的设置背景的问题

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

因此,我正在为我的FAB设置自定义背景。

 <com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/landing_offer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:srcCompat="@drawable/ic_batch_gold"
    app:backgroundTint="@color/white"
    app:layout_anchor="@id/bar"
    app:maxImageSize="50dp" />

给定的可绘制对象正在FAB上绘制。但是所有的颜色都消失了。都是黑色的,看上去很丑。如何在FAB上获得带有颜色的可绘制对象。谢谢。

这是我的vectordrawable

<vector android:height="42.859436dp" android:viewportHeight="42.94"
    android:viewportWidth="26.65" android:width="26.6dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#f0c419" android:pathData="M26.65,17A13.33,13.33 0,1 0,13.33 30.36,13.32 13.32,0 0,0 26.65,17"/>
    <path android:fillColor="#e64c3c" android:pathData="M13.33,3.7a13.21,13.21 0,0 1,8.14 2.8V0H5.18V6.5a13.26,13.26 0,0 1,8.15 -2.8"/>
    <path android:fillColor="#e64c3c" android:pathData="M13.33,30.36a13.26,13.26 0,0 1,-8.15 -2.8V42.94l8.15,-8.14 8.14,8.14V27.56a13.21,13.21 0,0 1,-8.14 2.8"/>
    <path android:fillColor="#ffe69f" android:pathData="M13.33,7.4l2.83,5.72l6.05,0.95l-4.29,4.45l1.33,5.91l-5.92,-2.57l-5.93,2.57l1.34,-5.91l-4.3,-4.45l6.05,-0.95l2.84,-5.72z"/>
</vector>

here is the one that is shown in layout editor

when i use my fab in bottmappbar

android android-layout material-design floating-action-button
1个回答
0
投票
这样做吧:

<com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_batch_gold" app:tint="@color/colorFabTint" app:backgroundTint="@color/white" app:layout_anchor="@id/bar" />

请注意

app:tint和

android:src attr而不是app:srcCompat

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