Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change shape of Extended Floating Action Button?

I am trying to change the shape of my action button from this default shape to a rectangle. Here is my xml:

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:cornerRadius="90dp"
        android:text="@string/create_player_text"
        android:fontFamily="@font/proximanova_semibold"
        app:layout_constraintHorizontal_bias="0.99"
        app:layout_constraintVertical_bias="0.01"/>

enter image description here

like image 289
QThompson Avatar asked Sep 09 '19 20:09

QThompson


1 Answers

If you want to change the shape of the ExtendedFloatingActionButton you can use the shapeAppearanceOverlay attribute in the layout:

    <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
        app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlayExtended"
        ../>

With:

  <style name="ShapeAppearanceOverlayExtended" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">0dp</item>
  </style>

If you want a corner radius just change the value in the <item name="cornerSize">0dp</item>.

enter image description here

like image 175
Gabriele Mariotti Avatar answered Sep 25 '22 13:09

Gabriele Mariotti