2

I want to display this png as my floating action button. But when I set this as my src, I get a black icon instead. How can I do it?

<com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@null"
        android:backgroundTint="@null"
        android:cropToPadding="true"
        android:outlineSpotShadowColor="@null"
        android:src="@drawable/ic_esaathi_icon"
        app:borderWidth="0dp"
        app:elevation="6dp"
        app:maxImageSize="56dp" />

Edit: Sarath Siva's answer works fine.

app:srcCompat="@drawable/icon_02"
Girish Garg
  • 58
  • 1
  • 9

2 Answers2

9

enter image description here

use it like this

 <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/icon_02"
        android:scaleType="center"
        app:maxImageSize="56dp"
        app:tint="@null"
        />
Sarath Siva
  • 547
  • 3
  • 14
3

remove background, try to set e.g. transparent or white color (or @null), but use custom lib attributes (e.g. app:) instead of built-in ones (android:)

app:backgroundTint="@android:color/transparent"
app:tint="@android:color/transparent"
snachmsm
  • 17,866
  • 3
  • 32
  • 74