I would like to use a gradient color instead of the traditional solid color for a Floating Action Button.
I already know how to modify the background color of the button, using ColorStateList
. Is there a way to implement the following drawable as a background tint color?
overlay.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#c25f82"
android:endColor="#5a3e60"
android:angle="-270" />
</shape>
Yes, you can set a Gradient to a FAB, I've just found a heck.
1.) Create a gradient.xml in drawable folder and add the following code in it,
2.) In your dimens.xml add this piece of line,
3.) In your Fab add
android:src="@drawable/gradient"
No. As you already noticed, tint is always a solid color. You can set anything as a background, but I guess such approach would break the support FAB.