Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android support library FloatingActionButton - padding on pre-lollipop devices?

This is my FAB definition:

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/button_capture_action_show_options"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|right"
        android:layout_margin="16dp"
        android:focusable="true"
        android:src="@drawable/c"

It seems that there's some extra padding when rendered on pre-lollipop devices and I can't seem to be able to remove it.

Lollipop rendering:

lollipop

Pre-lollipop rendering:

pre-lollipop

Any suggestions much appreciated..

like image 576
vkislicins Avatar asked Sep 27 '22 13:09

vkislicins


1 Answers

This is because of the way padding is implemented in the FAB on pre-Lollipop devices.

There's no way I know of to remove it on pre-Lollipop, but you can make it consistent (i.e. increase the padding on Lollipop and up) by setting app:useCompatPadding="true" on the FAB in the layout definition, or by using setUseCompatPadding.

It behaves this way because of the way shadows are drawn.

like image 63
snafu109 Avatar answered Oct 01 '22 21:10

snafu109