Reputation: 22956
I am trying to show a Snackbar in my activity. But it is being shown behind other views in the activity. How to show it as a top view?
Snackbar snack = Snackbar.make(referenceView, referenceView.getContext().getString(messageId), showLength);
snack.show();
referenceView
is nothing but a label in the same activity.
Upvotes: 3
Views: 711
Reputation: 6037
Make sure that your referenceView
is instance of CoordinatorLayout
, otherwise the Snackbar will anchor to a system view.
Per the Snackbar docs regarding the view
parameter:
Snackbar will try and find a parent view to hold Snackbar's view from the value given to view. Snackbar will walk up the view tree trying to find a suitable parent, which is defined as a CoordinatorLayout or the window decor's content view, whichever comes first.
Upvotes: 1