【发布时间】:2020-08-08 20:07:25
【问题描述】:
所以,我正在为我的 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" />
给定的drawable正在FAB上绘制。但它的所有颜色都消失了。它全是黑色的,看起来很丑。如何使用我的 FAB 上的颜色获取可绘制对象。谢谢。
这是我的矢量绘图
<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 所述,如果您的背景是彩色的,则添加
app:tint="@null"将解决问题
标签: android android-layout material-design floating-action-button