如何更改浮动操作按钮阴影颜色

时间:2016-02-27 07:12:30

标签: android button action floating

我想将黑色/灰色中的浮动操作按钮阴影颜色更改为 colorprimary /阴影自定义颜色**阴影示例,如下图所示**中心蓝色FAB按钮,浅蓝色阴影不是灰色阴影。但我们可以更改FAB按钮背景颜色。但正如您在图像中看到的那样,FAB按钮的蓝色阴影。我想要实现这一点。

enter image description here

3 个答案:

答案 0 :(得分:1)

试试这个 :: app:backgroundTint="@color/colorAccentGrey"

其中 colorAccentGrey = YourColor

xmlns:app="http://schemas.android.com/apk/res-auto" 放在XML的开头,如果你转发,

for Remove shadow :: app:elevation="0dp"

希望这会对你有帮助.. :)

答案 1 :(得分:0)

我认为你有两个选择:

  1. 正如@Uttam所说,改变FAB小部件的高程
  2. 制作自定义设计并将其作为图片嵌入到您的布局中,如下所示http://androidgifts.com/android-material-design-floating-action-button-tutorial/

答案 2 :(得分:0)

没有一个答案对我有用。所以我工作了。无论如何,它将给我足够的阴影效果

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_add_black"
        app:elevation="0dp" // disable outside shawdow
        app:borderWidth="30dp" // make borderwidth to 25dp or height of fab
        app:backgroundTint="#00E5FF" // now you will see only this color with shawdow 
        android:backgroundTint="#00E5FF" // since border is 30dp u ll not see this color and if you want to check reduce border width to 25dp then ull see this color in center as a small dot.
        />
相关问题