如何从DialogFragment调用FindViewById(android.r.id.content)?

发布于 2025-02-09 23:18:39 字数 370 浏览 0 评论 0原文

我试图在对话片段中调用小吃吧。但是它显示在系统按钮之上。为了避免这种情况,我需要在小吃栏调用中调用findViewById(android.r.id.content)。但不确定如何使其正确。

在父母片段中,我以这种方式打电话

        Snackbar.make(requireActivity().findViewById(android.R.id.content), "fdfdfdf", Snackbar.LENGTH_LONG).show();

,它可以很好地工作,但问题在于对话fragment位于小吃栏的顶部,因此看不到。因此,我需要从对话框片段中调用它。但是,当我从对话框中调用它时,零食吧台看不到。

I am trying to call snack bar in dialog fragment. But it shows on top of system buttons. To avoid this I need to call findViewById(android.R.id.content) in snack bar call. But not sure how to make it correct way.

In parent fragment I am calling this way

        Snackbar.make(requireActivity().findViewById(android.R.id.content), "fdfdfdf", Snackbar.LENGTH_LONG).show();

and it works perfectly but the problem is that dialogfragment is on top of the snack bar so its not visible. So I need to call it from dialog fragment. But when I call it from dialog snack bar not visible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抹茶夏天i‖ 2025-02-16 23:18:39

使您的对话框布局全屏具有透明背景,并将对话框内容保留在其中,然后在显示Snackbar时给出对话框布局的rootview。

[来源:https://stackoverflow.com/a/51150711/11831226]

Make your dialog layout fullscreen with transparent background and keep your dialog content inside it and then while showing the snackBar give rootview of the dialog layout.

[Source: https://stackoverflow.com/a/51150711/11831226]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文