Android PopupWindow showAsDropDown()无法正常工作 [英] Android PopupWindow showAsDropDown() not working properly

查看:430
本文介绍了Android PopupWindow showAsDropDown()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将PopupWindow与showAsDropDown(anchor)一起使用.当锚点在屏幕顶部时,它可以正常工作,但是在屏幕底部时,则不会显示任何内容.根据PopupWindow.showAsDropDown()的文档,这应该可以工作:

I am using PopupWindow with showAsDropDown(anchor). When the anchor is at the top of the screen it works fine, but when at the bottom of the screen nothing shows up. According to the documentation for PopupWindow.showAsDropDown() this should work:

http://developer. android.com/reference/android/widget/PopupWindow.html#showAsDropDown%28android.view.View%29

在锚定视图的左下角锚定的弹出窗口中显示内容视图.如果屏幕上没有足够的空间来完整显示弹出窗口,则此方法将尝试找到一个父滚动视图以如果没有父滚动视图可以滚动,则弹出窗口的左下角将固定在锚视图的左上角."

"Display the content view in a popup window anchored to the bottom-left corner of the anchor view. If there is not enough room on screen to show the popup in its entirety, this method tries to find a parent scroll view to scroll. If no parent scroll view can be scrolled, the bottom-left corner of the popup is pinned at the top left corner of the anchor view."

大概是,弹出窗口始终锚定在锚视图的左下角.我该如何解决?

Presumably, the popup is always anchored to the bottom-left corner of the anchor view. How do I fix this?

推荐答案

您可以尝试使用此方法.可能对您有帮助

You can try this .. may be it helps

mWindow.showAtLocation(mRootView, Gravity.BOTTOM|Gravity.LEFT, 0, distanceFromTop);

这篇关于Android PopupWindow showAsDropDown()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆