An Extended Floating Action Button displays the primary action in an application.
The Extended FAB is wider than the regular FloadtingActionButton, and it includes a text label.
Extended floating action buttons adjust their position and visibility in response to other UI elements on the screen.
The ExtendedFloatingActionButton widget provides a complete implementation of Material Design’s extended FAB component
Note: ExtendedFloatingActionButton is a child class of Material Button, rather than FloatingActionButton. This means that several attributes which are applicable to FloatingActionButton have different naming in ExtendedFloatingActionButton.
You just need to follow few steps to add ExtendedFloatingActionButton in your app ->
In order to use Material Components for Android, and the latest versions of the Support Libraries, you will have to update your app’s complieSdkVersion to 28
You also need to migrate your project with AndroidX.
For AndroidX migration, you can refer this link -> AndroidX
You need to change your app theme to inherit from a Material Components theme.
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
Note: You can use any child of “Theme.MaterialComponents” as a parent theme of your application.
Now, if you want to expand or shrink your button at any point, you need to call only two methods ->
To learn more about material extend floating action button, you can refer this link – Material Extended Floating Action Button
Hope, this blog is helpful for you to add Extended Floating Action Button in android app.
Be the first to comment.