这是我用来在GridView项上长按时显示弹出窗口的简化代码。
当最右边的项时,弹出窗口会调整到屏幕内。
但是,在靠近屏幕底部的项目上,弹出窗口被裁剪(一部分在屏幕外)。
如何解决这个问题?
当最右边的项时,弹出窗口会调整到屏幕内。
但是,在靠近屏幕底部的项目上,弹出窗口被裁剪(一部分在屏幕外)。
如何解决这个问题?
PopupWindow mDropDownMenu= new PopupWindow(list, WRAP_CONTENT, WRAP_CONTENT);
mDropDownMenu.showAsDropDown(aView);
文档中关于showAsDropDown(View anchor)的说明如下:
* 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.
*
但它总是固定在左下角,而不向左上方移动。