As described in the documentation, by default it takes the color set in styles.xml attribute colorAccent.
The background color of this view defaults to the your theme’s colorAccent. If you wish to change this at runtime then you can do so via setBackgroundTintList(ColorStateList).
If you wish to change the color
- in XML with attribute app:backgroundTint
<android.support.design.widget.FloatingActionButton
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="https://stackoverflow.com/questions/30969455/@drawable/ic_add"
app:backgroundTint="@color/orange"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal" >
- in code with .setBackgroundTintList (answer below by ywwynm)
As @Dantalian mentioned in the comments, if you wish to change the icon color for Design Support Library up to v22 (inclusive), you can use
android:tint="@color/white"
For Design Support Library since v23 for you can use:
app:tint="@color/white"
Also with androidX
libraries you need to set a 0dp border in your xml layout:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="https://stackoverflow.com/questions/30969455/@drawable/ic_add"
app:backgroundTint="@color/orange"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal" />