Android FAB backgroundTintList,不';t工作并设置边框颜色

Android FAB backgroundTintList,不';t工作并设置边框颜色,android,floating-action-button,Android,Floating Action Button,如果您在XML中使用它,它可以工作,但是您不能通过编程来设置它。我正在使用这个库: implementation 'com.google.android.material:material:1.0.0' 例如: filterHistoryFab.backgroundTintList = ContextCompat.getColorStateList(context!!, R.color.pink) XML: 风格: <style name="FloatingActionButton

如果您在XML中使用它,它可以工作,但是您不能通过编程来设置它。我正在使用这个库:

implementation 'com.google.android.material:material:1.0.0'
例如:

filterHistoryFab.backgroundTintList = ContextCompat.getColorStateList(context!!, R.color.pink)
XML:


风格:

<style name="FloatingActionButton">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:backgroundTint">@color/dark_blue</item>
    <item name="android:layout_margin">@dimen/fab_margin</item>
    <item name="android:background">?attr/selectableItemBackgroundBorderless</item>
</style>

包装内容
包装内容
@颜色/深蓝色
@尺寸/加工余量
?属性/可选择项背景无边界
背景应该是粉红色,但它保持蓝色,后面有一些粉红色。
链接到它的外观:

我猜出来了。如果在STYLE
backgroundTint
中设置,它将无法按编程方式工作。也许这是一个错误。因此,解决方案就是删除这一行:

 <item name="android:backgroundTint">@color/dark_blue</item>
@color/深蓝色

它工作得很好。

谢谢你的回答,但那是因为图标的色调而不是背景。
 <item name="android:backgroundTint">@color/dark_blue</item>