diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-01-30 18:31:17 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-01-30 18:31:21 +0000 |
| commit | 9f5d2b08868a990bc4d1f6b0bbf52bf14b60c3af (patch) | |
| tree | e992f03b98c4f4933fd563dc71cca9c62a21ca1e /core/java | |
| parent | fda076a12ed641d5ab53933c4aac9e8063c580d0 (diff) | |
| parent | 50df07a1add902da01018756c213169e4e126a28 (diff) | |
Merge "Don't scroll popup parent in response to parent scrolling"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/widget/PopupWindow.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/core/java/android/widget/PopupWindow.java b/core/java/android/widget/PopupWindow.java index 46324a3807e7..5199b26e59e6 100644 --- a/core/java/android/widget/PopupWindow.java +++ b/core/java/android/widget/PopupWindow.java @@ -232,7 +232,7 @@ public class PopupWindow { mDecorView.getLayoutParams(); updateAboveAnchor(findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff, - p.width, p.height, mAnchoredGravity)); + p.width, p.height, mAnchoredGravity, false)); update(p.x, p.y, -1, -1, true); } } @@ -1237,7 +1237,7 @@ public class PopupWindow { preparePopup(p); final boolean aboveAnchor = findDropDownPosition(anchor, p, xoff, yoff, - p.width, p.height, gravity); + p.width, p.height, gravity, mAllowScrollingAnchorParent); updateAboveAnchor(aboveAnchor); p.accessibilityIdOfAnchor = (anchor != null) ? anchor.getAccessibilityViewId() : -1; @@ -1529,10 +1529,12 @@ public class PopupWindow { * @param xOffset absolute horizontal offset from the left of the anchor * @param yOffset absolute vertical offset from the top of the anchor * @param gravity horizontal gravity specifying popup alignment + * @param allowScroll whether the anchor view's parent may be scrolled + * when the popup window doesn't fit on screen * @return true if the popup is translated upwards to fit on screen */ private boolean findDropDownPosition(View anchor, WindowManager.LayoutParams outParams, - int xOffset, int yOffset, int width, int height, int gravity) { + int xOffset, int yOffset, int width, int height, int gravity, boolean allowScroll) { final int anchorHeight = anchor.getHeight(); final int anchorWidth = anchor.getWidth(); if (mOverlapAnchor) { @@ -1586,7 +1588,7 @@ public class PopupWindow { final int scrollY = anchor.getScrollY(); final Rect r = new Rect(scrollX, scrollY, scrollX + width + xOffset, scrollY + height + anchorHeight + yOffset); - if (mAllowScrollingAnchorParent && anchor.requestRectangleOnScreen(r, true)) { + if (allowScroll && anchor.requestRectangleOnScreen(r, true)) { // Reset for the new anchor position. anchor.getLocationInWindow(drawingLocation); outParams.x = drawingLocation[0] + xOffset; @@ -2182,15 +2184,19 @@ public class PopupWindow { } final boolean aboveAnchor = findDropDownPosition(anchor, p, mAnchorXoff, mAnchorYoff, - width, height, gravity); + width, height, gravity, mAllowScrollingAnchorParent); updateAboveAnchor(aboveAnchor); final boolean paramsChanged = oldGravity != p.gravity || oldX != p.x || oldY != p.y || oldWidth != p.width || oldHeight != p.height; - // If width and mWidth were both < 0 then we have a MATCH_PARENT/WRAP_CONTENT case. - // findDropDownPosition will have resolved this to absolute values, - // but we don't want to update mWidth/mHeight to these absolute values. - update(p.x, p.y, width < 0 ? width : p.width, height < 0 ? height : p.height, paramsChanged); + + // If width and mWidth were both < 0 then we have a MATCH_PARENT or + // WRAP_CONTENT case. findDropDownPosition will have resolved this to + // absolute values, but we don't want to update mWidth/mHeight to these + // absolute values. + final int newWidth = width < 0 ? width : p.width; + final int newHeight = height < 0 ? height : p.height; + update(p.x, p.y, newWidth, newHeight, paramsChanged); } /** |
