如何更改FAB背景颜色 [英] How to change FAB background color
本文介绍了如何更改FAB背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用浮动操作按钮",并且想要更改背景颜色.
I am using Floating Action Button and I want to change the background color.
这是我的代码
<android.support.design.widget.FloatingActionButton
android:id="@+id/btnfab"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="right|center_vertical"
android:layout_marginBottom="20dp"
android:src="@drawable/search" />
这是我用来尝试实现此目标的代码:
Here is the code I am using to try and achieve this:
1- android:background="@color/mycolor"
2- android:backgroundTint="@color/white"
如图所示,我也在FAB上遇到了麻烦.我应该如何去除那些角落阴影?
I am also getting corners on my FAB as shown in image. How should I remove those corner shadows?
推荐答案
您可以通过将以下属性添加到FloatingActionButton
:
You can remove problematic shadow by adding this attributes to your FloatingActionButton
:
app:borderWidth="0dp"
app:elevation="6dp"
FloatingActionButton
没有背景色.您可以通过以下方式更改该组件的颜色:
There is no background color for FloatingActionButton
. You change this component color by:
app:backgroundTint="@color/YOURCOLOR"
记住要在您的父级布局中包含以下行:
Remember to have in your parent layout following line:
xmlns:app="http://schemas.android.com/apk/res-auto"
这篇关于如何更改FAB背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文