How to make a Floatingactionbutton square or rectangular?

Asked

Viewed 354 times

6

I have 2 Floating Action Buttons on screen. How can I make them rectangular?

  • As far as Fab know are always round, I’ve used a cardview with a button to simulate the effect.

1 answer

7


One solution to make it square would be to use borderWidth inserting 0dp for your FloatingActionButton. Then it would result in:

Code

app:borderWidth="0dp"

Floatingactionbutton:

<android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        app:borderWidth="0dp"
        android:id="@+id/fab_1"
        android:layout_marginBottom="16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|bottom"
        android:src="@drawable/abc_ic_clear_mtrl_alpha"/>

See the code in Gist.

Imagery

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.