Add
app.strokeColor = "#000033"
app.strokeWidth = "3dp"
in your floating action button xml..
for example:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/vector_nav_qr_scanner"
app:backgroundTint="@android:color/white"
app:layout_anchor="@id/bottom_app_bar"
app:strokeColor = "#000033"
app:strokeWidth = "3dp" />
edit: app:strokewidth and app:strokeColor is working for ExtendedFloatingActionButton. Sorry, that's my fault.
You can use
app:borderWidth="4dp" in stead of app:strokeWidth = "3dp". remove strokeColor. there showes little border.
i hope it will help you.
please let me know if it doesn't work.
OR
define custom shape in drawable folder
fab_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false" >
<solid android:color="@android:color/transparent" />
<!-- here set the width and color of your border -->
<stroke
android:width="5dp"
android:color="@android:color/darker_gray" />
</shape>
then wrap your FloatingActionButton with a layout. use fab_bg.xml file in layout's background.
for example:
<LinearLayout
android:id="@+id/fabWrapperId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/fab_bg"
android:padding="5dp">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/app_name"
android:src="@drawable/vector_nav_qr_scanner"
app:backgroundTint="@android:color/white"
app:layout_anchor="@id/bottom_app_bar"
app:fabSize="normal" />
</LinearLayout>
NB: make sure your stroke width from fab_bg and layout padding keep the same.