According to doc, the color of the view defaults to our theme's colorAccent. I tried changing colorAccent in my styles resource file, but nothing happened:
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorAccent">#d81b60</item>
</style>
So I tried changing colorSecondary instead:
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorSecondary">#d81b60</item>
</style>
And it worked. So my question is does it really depend on colorAccent? If yes, when?
Starting with the version 1.1.0 of the Material Components Library the default style of the FloatingActionButton is based on ?attr/colorSecondary:
<style name="Widget.MaterialComponents.FloatingActionButton" parent="Widget.Design.FloatingActionButton">
<item name="backgroundTint">?attr/colorSecondary</item>
</style>
Starting with the version 1.2.0 of the Material Components Library the default style of the FloatingActionButton is:
<style name="Widget.MaterialComponents.FloatingActionButton" parent="Widget.Design.FloatingActionButton">
<item name="backgroundTint">@color/mtrl_fab_bg_color_selector</item>
<!-- .... -->
</style>
Starting from the version 1.2.0 the @color/mtrl_fab_bg_color_selector is based on the ?attr/colorSecondary:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorSecondary" android:state_enabled="true"/>
<item android:alpha="0.12" android:color="?attr/colorOnSurface"/>
</selector>
In the version 1.0.0 the backgroundTint was based on ?attr/colorAccent:
<style name="Widget.Design.FloatingActionButton" parent="android:Widget">
<item name="backgroundTint">?attr/colorAccent</item>
...
</style>
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