benleung
benleung

Reputation: 871

Snackbar is covering the floating action button for coordinator layout in fragment

I got an coordinator layout in Activity for showing a snackbar which may ask user to confirm exit when the user pressed back button.

Also I have got a coordinator layout inside a fragment for showing the floating action button in that fragment.

However, the snackbar will covering the floating action button inside the fragment. Isn't it the only way is to keep one coordinator layout? Any other way to keep this structure and the FAB will response to the snackbar showing and move up?

Upvotes: 0

Views: 803

Answers (1)

user8491011
user8491011

Reputation:

Pass the FloatingActionBar's View into SnackBar.

Sample Code:

SnackBar.make(findViewById(R.id.fab),"Hello StackOverflow",SnackBar.LENGTH_SHORT).show();

Where, id fab is the id of FloatingActionButton in layout xml.

Upvotes: 1

Related Questions