From bdd2c25ef69148e52dd406615efbd4e5ad41b335 Mon Sep 17 00:00:00 2001 From: Vladislav Kaznacheev Date: Wed, 29 Nov 2017 09:30:11 -0800 Subject: Fix horizontal position of tooltip in a Dialog When calculating the horizontal offset, use the top level view's width instead of getWindowVisibleDisplayFrame (which is misleading for Dialog windows). Bug: 69911773 Test: manual Change-Id: I040917d5beb123cc137da5a0c926a45a12e66234 --- core/java/com/android/internal/view/TooltipPopup.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/java/com/android/internal/view/TooltipPopup.java b/core/java/com/android/internal/view/TooltipPopup.java index d38ea2c19af4..24f0b0cc91c5 100644 --- a/core/java/com/android/internal/view/TooltipPopup.java +++ b/core/java/com/android/internal/view/TooltipPopup.java @@ -142,7 +142,7 @@ public class TooltipPopup { mTmpAnchorPos[1] -= mTmpAppPos[1]; // mTmpAnchorPos is now relative to the main app window. - outParams.x = mTmpAnchorPos[0] + offsetX - mTmpDisplayFrame.width() / 2; + outParams.x = mTmpAnchorPos[0] + offsetX - appView.getWidth() / 2; final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); mContentView.measure(spec, spec); @@ -157,6 +157,9 @@ public class TooltipPopup { outParams.y = yBelow; } } else { + // Use mTmpDisplayFrame.height() as the lower boundary instead of appView.getHeight(), + // as the latter includes the navigation bar, and tooltips do not look good over + // the navigation bar. if (yBelow + tooltipHeight <= mTmpDisplayFrame.height()) { outParams.y = yBelow; } else { -- cgit v1.2.3-59-g8ed1b