Reputation: 932
As title says, I don't know how to fix this issue. I read this problem but that was in 2018, I'm not very familiar with all those libraries and dependencies how it all works. But judging from my Declared Dependencies, from Android Studio, this is what I got:
I would like to add some kind of "Attach document" icon/image to the FAB. I tried to do this by adding a New Vector
asset, but images do not appear in my drawable folder. How can I add a nice icon/image to my project, and set it to a FAB?
Here is XML:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:icon="@drawable/attache_file">
</com.google.android.material.floatingactionbutton.FloatingActionButton>
Upvotes: 3
Views: 2958
Reputation: 4108
I found the solution, just add this below statement inside dimens.xml
<dimen name="design_fab_image_size" tools:override="true">56dp</dimen>
And must need to add app:tint="@null" inside your FAB design xml
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/bottomBar"
app:srcCompat="@drawable/ic_logo"
app:tint="@null" />```
Happy to help :)
Upvotes: 5
Reputation: 364868
To use the com.google.android.material.floatingactionbutton.FloatingActionButton
add the Material Components library:
implementation 'com.google.android.material:material:1.1.0'
Then use the app:srcCompat
attribute:
<com.google.android.material.floatingactionbutton.FloatingActionButton
style="@style/Widget.MaterialComponents.FloatingActionButton"
app:srcCompat="@drawable/..."
.../>
Upvotes: 3
Reputation: 5257
Per the documentation you have to use android:src="@drawable/attache_file"
Upvotes: 2