Home > Net >  how to change Floating Action Button border color?
how to change Floating Action Button border color?

Time:10-11

i want to change border color of FAB to red,but i tried many way but it still not work.

my VectorDrawable

<?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" />
    <stroke
        android:width="3dp"
        android:color="@color/red" />
</shape>

and i use it in mylayout.xml

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@ id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:elevation="2dp"
        app:rippleColor="@color/red"
        app:fabSize="auto"
        app:borderWidth="0dp"
        android:background="@drawable/oval_border_red"
        android:backgroundTint="@color/white"
        android:src="@drawable/ic_close_24"
        app:tint="@color/red"
        android:focusable="true" />

it just change background and image color like this

enter image description here

I really appreciate your help and have a nice day!

CodePudding user response:

try this code :-

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@ id/floatingActionButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/white"
        android:clickable="true"
        android:elevation="2dp"
        android:focusable="true"
        android:src="@drawable/ic_close_24"
        app:backgroundTint="@color/red"
        app:borderWidth="1dp"
        app:fabSize="auto"
        app:rippleColor="@android:color/holo_red_light"
        app:tint="@android:color/holo_red_light" />

i just add app:backgroundTint="@android:color/holo_red_light"

  • Related