How can I implement such a snackbar. To have it with round edges and show above fab and was not stretched across the width of the screen
Snackbar like google io 2018 android
1.5k views Asked by alex At
3
There are 3 answers
2
On
Use the Snackbar in the Material Components library.
As default it has rounded corners.
Use the setAnchorView method to make a Snackbar appear above a specific view, in your case the fab button.
Snackbar snackbar = Snackbar.make(view, "...", Snackbar.LENGTH_LONG);
snackbar.setAnchorView(fab);
snackbar.show();
Also you can customize the margin using the snackbarStyle attribute in the app theme.
<style name="AppTheme" parent="Theme.MaterialComponents.Light">
....
<item name="snackbarStyle">@style/MySnackbar</item>
</style>
In the snackbar style use the android:layout_margin attribute.
<style name="MySnackbar" parent="@style/Widget.MaterialComponents.Snackbar">
<item name="android:layout_margin">32dp</item>
</style>

Try to adding this dependency.
Then can add Cafe Bar using this code.
If you need more customization visit the documentation here.