更改作为 BottomAppBar 一部分的浮动操作按钮下方的背景颜色

时间:2021-01-14 11:52:59

标签: android android-layout floating-action-button android-bottomnav

我想要一个半透明的浮动操作按钮,它是底部应用栏的一部分。我可以调整所有颜色,但 FAB 本身下面的颜色除外。

enter image description here

我猜它属于底部应用栏,但我不知道如何更改它。你知道怎么做吗?它不适合我的配色方案,因为它的黑色比其他黑色更深。还有一些奇怪的白色圆圈。如果可能的话,我也想摆脱这个。

这是他们的代码:

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:menu="@menu/bottom_app_bar" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/commit_FloatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:backgroundTint="#5A396283"
        app:layout_anchor="@id/bottomAppBar"
        app:srcCompat="@drawable/ic_round_check_24"
        app:tint="#D3D3D3" />

1 个答案:

答案 0 :(得分:1)

你可以简单地做到:

  1. android:backgroundTint="@android:color/transparent" 上设置 FloatingActionButton
  2. 创建一个自定义可绘制对象作为单独的资源文件,其中包含背景(您显然可以控制)和选中可绘制对象。
  3. app:srcCompat 值设置为指向新创建的自定义资源
相关问题