Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use the real Floating Action Button (FAB) Extended?

Tags:

To remove any doubts or thoughts about duplicate: on Material Design is defined what is "extended".

FAB - Extended FAB

But most of the people confuses "extended" with "Type of Transition: Speed Dial", what make hard to find solutions. Like here

FAB - Type of Transition: Speed Dial

Question So what I'm looking forward is how setup the FAB with text and a extended size.

Today my code is like this:

<android.support.design.widget.FloatingActionButton     android:id="@+id/maps_main_distance_btn"     android:layout_width="0dp"     android:layout_height="wrap_content"     android:layout_marginBottom="8dp"     android:text="@string/str_distance_btn"     app:elevation="0dp"     app:layout_constraintBottom_toBottomOf="parent"     app:layout_constraintEnd_toEndOf="parent"     app:layout_constraintStart_toStartOf="parent" /> 

But my button look like this:

enter image description here

No text and no right format. I'm using it in a Constraint Layout.

like image 903
Canato Avatar asked May 15 '18 16:05

Canato


People also ask

Where do you put the floating action button?

The button should be placed in the bottom right corner of the screen. The recommended margin for the bottom is 16dp for phones and 24dp for tablets. In the example above, 16dp was used. The actual drawable size should be 24dp according to the Google design specs.


1 Answers

  1. Add the dependencies in your Gradle file:
implementation 'com.google.android.material:material:1.1.0-alpha04' 

in your xml file:

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton             android:id="@+id/fab"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="bottom|end"             android:layout_alignParentBottom="true"             android:layout_alignParentEnd="true"             android:layout_margin="@dimen/fab_margin"             android:text="Create"             app:icon="@drawable/outline_home_24" /> 
like image 69
Alexander HD Avatar answered Sep 22 '22 13:09

Alexander HD