Created
June 11, 2013 09:34
-
-
Save brnhffmnn/5755653 to your computer and use it in GitHub Desktop.
ActionBarSherlock: IcsListPopupWindow screen clipping method. Untested. Call in show(): mPopup.setWindowLayoutMode(widthSpec, heightSpec);
applyClipToScreen();
//XXX mPopup.setClipToScreenEnabled(true);
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void applyClipToScreen() { | |
final WindowManager.LayoutParams p = (LayoutParams) mPromptView.getLayoutParams(); | |
mDropDownAnchorView.getLocationOnScreen(mScreenLocation); | |
final Rect displayFrame = new Rect(); | |
mDropDownAnchorView.getWindowVisibleDisplayFrame(displayFrame); | |
final int displayFrameWidth = displayFrame.right - displayFrame.left; | |
int right = p.x + p.width; | |
if (right > displayFrameWidth) { | |
p.x -= right - displayFrameWidth; | |
} | |
if (p.x < displayFrame.left) { | |
p.x = displayFrame.left; | |
p.width = Math.min(p.width, displayFrameWidth); | |
} | |
if (mPromptPosition == POSITION_PROMPT_ABOVE) { | |
int popupTop = mScreenLocation[1] + mDropDownHorizontalOffset - mDropDownWidth; | |
if (popupTop < 0) { | |
p.y += popupTop; | |
} | |
} else { | |
p.y = Math.max(p.y, displayFrame.top); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment