如何在点击位置显示PopoupWindow?

发布于 2024-09-14 20:07:59 字数 249 浏览 4 评论 0原文

我试图在 Android 中的点击位置显示一个 PopupWindow。 我读到 Android 由于某种原因不支持获取点击坐标。

我想做一些类似于 Android 2.1+ 上的联系人上出现的小弹出窗口,当您选择一个人的图标时,行位置会出现一个窗口,显示联系该人的不同选项。他们也在 Twitter 应用程序中做了类似的事情。

我想它的作用更像是上下文菜单,但我读到的是上下文菜单无法自定义。这个位置的弹出窗口是如何完成的?

谢谢。

I'm trying to show in Android a PopupWindow at the click location.
I read that Android does not support getting the click coordinates for some reason.

I want to do something like the little popup that appears on the contacts on Android 2.1+ when you select a person's icon and a window appears at the row location showing different options to contact that person. Also in the twitter application they do something similar.

I guess it is acting more like a Context Menu, but what I read is that Context Menus cannot be customized. How are this popup windows at location done?

Thanks.

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

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

发布评论

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

评论(1

终陌 2024-09-21 20:07:59

对于 PopupWindow 的情况,有一个更简单的选项:

PopupWindow 的 showAsDropDown(View, int offsetx, int offsety) 方法将按特定偏移量将窗口锚定到给定视图。

There is an easier option for the case of PopupWindow:

The method showAsDropDown(View, int offsetx, int offsety) of the PopupWindow will anchor the window to the given view by the specific offset.

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