6

I'm trying to include a floating action button into my app. This works fine for devices with API 21 and above. But for devices with an earlier version, the drop shadow looks like this:

enter image description here

The xml for the floating action button looks like this:

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/floatingActionButton"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:clickable="true"
    android:src="@drawable/ic_fab_add"
    android:layout_marginLeft="16dp"
    app:elevation="6dp"
    app:borderWidth="0dp"
    android:layout_above="@+id/destinationContainer" />

I use the support design library 'com.android.support:design:23.1.1'to include the floating action button.

Does anybody know what I do wrong?

Thanks.

EDIT:

I figured out, that the custom size of 40dp is the problem. The broken shadows probably only appear in the space between 40dp and the original size.... This does not fix my problem, but its a hint

Sneek
  • 106
  • 5

1 Answers1

0

try adding this code to your xml

app:elevation="@dimen/floating_button_elevation"
app:borderWidth="0dp"
app:rippleColor="@color/your_ripple_color"
app:backgroundTint="@color/your_bg_color"
CodingRat
  • 1,934
  • 3
  • 23
  • 43
  • Unfortunaly, this does not work... The drop shadow looks still the same. – Sneek Jan 02 '16 at 18:07
  • try this it may help http://stackoverflow.com/questions/30576450/floatingactionbutton-example-with-support-library – CodingRat Jan 02 '16 at 18:14
  • I figured out, that the custom size of 40dp is the problem. The broken shadows are the space between the original size of the button and my custom size of 40dp. I hope to find a fix for it. Otherwise I have to mock the button. – Sneek Jan 02 '16 at 18:19
  • @Sneek did you find any solution for your custom sized fab? I am facing similar issue – Sujan Shrestha Jun 22 '17 at 00:14