我正在尝试在我的 Activity 中显示一个 Snackbar。但它在 Activity 中显示在其他 View 后面。如何显示为俯 View ?
Snackbar snack = Snackbar.make(referenceView, referenceView.getContext().getString(messageId), showLength);
snack.show();
referenceView
只是同一 Activity 中的一个标签。
最佳答案
确保您的 referenceView
是 CoordinatorLayout
的实例,否则 Snackbar 将锚定到系统 View 。
根据 Snackbar docs关于 view
参数:
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.
关于android - SnackBar 落后于其他 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39814645/