android7.0 PopupWindow showAsDropDown问题

发布于 2021-12-05 00:42:26 字数 362 浏览 714 评论 5

关键代码:timeMenuWindow.showAsDropDown(selectTimeLayout);

在android7.0以下都是正常的。


android7.0就有问题


求指点~

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

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

发布评论

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

评论(5

青萝楚歌 2021-12-05 06:42:06

可以,完美解决,找了半天问题,感谢~

本宫微胖 2021-12-05 06:22:14

没有~

终遇你 2021-12-05 06:16:52

解决没有?

凌乱心跳 2021-12-05 05:28:43

可以,妥妥的解决了~

墨洒年华 2021-12-05 03:05:33

遇到同样的问题

PopupWindow: 

Android 7.0之前,在指定位置弹出popupwindow可以用showAsDropDown(View anchor, int xoff, int yoff),showAtLocation(View parent, int gravity, int x, int y)。但在android 7.0上,用showAsDropDown()在popupwindow为全屏时,会有弹出位置异常情况,需用showAtLocation()才能正常显示:

if (Build.VERSION.SDK_INT < 24)
        {
            dropListPopupWindow.showAsDropDown(this, 0, 5);
        }
        else
        {
            // 适配 android 7.0
            int[] location = new int[2];
            getLocationOnScreen(location);
            int x = location[0];
            int y = location[1];
            Log.e(getClass().getSimpleName(), "x : " + x + ", y : " + y);
            dropListPopupWindow.showAtLocation(this, Gravity.NO_GRAVITY, 0, y + getHeight() + 5);
        }

参考:http://blog.csdn.net/dxxs19/article/details/53572833

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