How to change the Background color of Android Floating Button

Android floating action button is used to trigger primary app UI events.

When you create an activity page in Android Studio, it will generate a floating action button.

The background color of the floating action button will default to your project colorAccent.

What if you want to change the background color of android floating action button?

The simplest way to learn how to change the background color of android floating action button is to set the button property backgroundTintto any color of your choice app:backgroundTint="#bc0000"

activity_change_fab_color.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:background="#ededed">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="15dp"
            android:src="@android:drawable/ic_input_add"
            android:tint="#ffffff"
            app:backgroundTint="#bc0000"
            app:borderWidth="0dp" />

    </LinearLayout>

</RelativeLayout>

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.

 

 

Add a Comment