I've tried googling pictures of one, but I'm wondering if there's a way for me to specify the color of the floating action button using hex in the layout file. I want the color to make sense with the rest of the app.
Asked
Active
Viewed 3,197 times
0
-
The best places to search icons are: [materialdesignicons.com](https://materialdesignicons.com/) and [google design icons](https://design.google.com/icons/index.html) – Andrii Abramov Sep 26 '16 at 07:42
2 Answers
0
You can change the color of FAB by app:backgroundTint
Attribute in FloatingActionButton XML
<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="@drawable/ic_myicon"
app:backgroundTint="@color/mycolor"
app:fabSize="normal"
app:elevation="5dp">

deejay
- 572
- 4
- 18
-
Will that work with an image I get off google? There's no FAB icon in my drawables directory. – Matt Sep 26 '16 at 08:03
-
0
you can set float action button color using colorAccent in syles.xml:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="drawerArrowStyle">@style/drawer_toggle</item>
</style>
or if you don't want change colorAccent, you can use backgroundTint as deejay said.

saeed shahini
- 1,847
- 2
- 13
- 15
-
Will that work if I download an image from google and put it in my drawables directory? My drawables directory didn't come with a floating action button icon – Matt Sep 26 '16 at 08:06