The code for FAB:
I tried a bunch of different answers but all had their shortcomings or didn't work with the material FAB
.
When I realized this is not what it is meant for I simply replaced it with an ImageView
. This works great and looks identical.
<ImageButton
android:id="@+id/floatingActionButton"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="@drawable/fab_gradient"
android:elevation="6dp"
... />
fab_gradient.xml:
<ripple android:color="?attr/colorControlHighlight"
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<item>
<shape android:shape="oval">
<gradient
android:type="linear"
android:angle="90"
android:startColor="@color/startColor"
android:endColor="@color/endColor" />
</shape>
</item>
<item android:drawable="@drawable/vector_icon" android:gravity="center" />
</layer-list>
</item>
</ripple>