0

I am trying to get a shadow under my Floating action button but its not showing.

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="20dp"
    android:background="@color/colorAccent"
    android:clickable="true"
    android:scaleX="-1"
    android:src="@drawable/ic_share"
    app:borderWidth="0dp"
    app:elevation="21dp"
    app:fabSize="normal"
    app:itemIconTint="@color/white" />

<Custom View/>

This is how it shows now: No shadow fab

What am i doing wrong?

Edit 1: The suggested fix to add app:borderWidth="0dp" doesn't fix my problem

Edit 2: Problem solved apparently using android:scaleX="-1" removes the shadow

Flab98
  • 31
  • 1
  • 6

1 Answers1

1

you need to just add app:borderWidth="0dp" to your FloatingActionButton

Sample code

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="20dp"
    app:borderWidth="0dp"
    android:background="@color/colorAccent"
    android:clickable="true"
    android:src="@drawable/ic_share"
    app:borderWidth="0dp"
    app:elevation="21dp"
    app:fabSize="normal"
    app:itemIconTint="@color/white" />

and make sure

Check manifest file in Application tag and delete them

android:hardwareAccelerated="false"
android:largeHeap="true"

But if you need these options then shadows and transformation animations will not work

AskNilesh
  • 67,701
  • 16
  • 123
  • 163