FAB 背景色调不会在片段中发生变化,但会在 activity 中发生变化?

FAB background tint does not change in fragment but changes in activity?

我之前在我的 activity 中有这个工厂并且工作正常,但现在我已经将我的代码从 activity 转移到一个片段。现在我的布局中有 3 个 Fab,我无法更改背景颜色或其中任何一个。这是我的代码。我做错了什么或出了什么问题?任何帮助将不胜感激?

P.S。我的 fab 按钮的颜色是默认的 Aqua 颜色,甚至不是我的应用程序强调色,我可以在我的布局编辑器中看到反映的变化,但在我的设备上看不到!!

 <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab_change_map_type"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="16dp"
        android:backgroundTint="@color/color_accent"
        android:onClick="@{(v) -> viewModel.onClick(v)}"
        android:src="@drawable/ic_change_map_display_type"
        android:visibility="@{viewModel.routeInfoViewModel.routeInfoViewEnabledLive ? View.GONE : View.VISIBLE}"
        app:borderWidth="0dp"
        app:fabSize="mini"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/card_gps_error"
        app:rippleColor="@color/color_accent" />

您应该为 FloatingActionButtonsbackgroundTint 属性 使用 app: 命名空间。 Material Components reference

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab_change_map_type"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ...
    app:backgroundTint="@color/color_accent"
    ...
     />