I am trying to set the background of a FAB to a different color in XML. I know I could do this in code, but that would also require a lot of inconvenient refactoring on my part.
<android.support.design.widget.FloatingActionButton
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#F38E1B"
android:id="@+id/fab"/>

For some reason, the background stays blue when it should be orange. I have tried setting the background to a drawable as well but that yields the same results.
Is this a bug or am I just missing something?
I also tried to use the same approach as you and was getting the same result. My solution was to was to this:
<item name="colorAccent">@color/yourColor</item>
in my application theme.
However, this color will also be used in all your widgets.
Hope this helps!
I had the same problem. This is how I solve my issue: I just create a new theme to my button.
My FAB xml:
<android.support.design.widget.FloatingActionButton
...
android:theme="@style/MapButton"/>
My new theme in style.xml:
<style name="MapButton" parent="AppTheme">
<item name="colorAccent">#FFFFFF</item></style>
I created a new theme based on my App's theme and changed only the color I wanted.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With