Extended floating action buttons are used for a special type of promoted action. They are distinguished by an icon and a text floating above the UI and have special motion behaviors related to morphing, launching, and the transferring anchor point.

Extended floating action buttons may have icon and text, but may also hold just an icon or text.

As this class descends from MaterialButton , you can control the icon which is displayed via setIcon(android.graphics.drawable.Drawable) , and the text via setText(CharSequence) .

The background color of this view defaults to the your theme’s colorSecondary . If you wish to change this at runtime then you can do so via setBackgroundTintList(android.content.res.ColorStateList) .

 

Step 1: Add dependency in build.gradle to material (latest version)

 

Step 2: Adjust app theme in styles.xml to one of Theme.MaterialComponents

 

Step 3: Add EFAB in your layout.xml

 

Step 4: Java implementation

 

Result:

20210104_1333571

 

Soruce:
https://proandroiddev.com/android-extendedfloatingactionbutton-quick-tips-to-start-using-it-today-29cfd4c28f43

Documentation:
https://developer.android.com/reference/com/google/android/material/floatingactionbutton/ExtendedFloatingActionButton

Spread the love

Leave a Reply

Your email address will not be published.