This is a simplified code for what I use to show a popup window when making a long click on a GridView item.
When the item on the most right the popup window gets adjusted to be within the screen.
But when the item near the bottom of the screen the popup window is cropped(part of it outside the screen).
How to get this fixed?
PopupWindow mDropDownMenu= new PopupWindow(list, WRAP_CONTENT, WRAP_CONTENT);
mDropDownMenu.showAsDropDown(aView);
aView is the GridView item.
The documentation says about 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.
*
But it's always pinned to the bottom-left and don't go up-left.
It turns out that I MUST set the drop down menu height to avoid this problem
List<DropDownListItem> items;
dropDown.setHeight( toPixels( 30 * items.size() ) );