From 8e7ea1179a36bfa64b1da36243f8f4da13781560 Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Mon, 25 Apr 2016 10:14:14 -0700 Subject: [PATCH] Fix Popover location in Events Reviewed By: andreicoman11 Differential Revision: D3219054 fb-gh-sync-id: cc25bd63be284ae7e8232652936a67fd792feabc fbshipit-source-id: cc25bd63be284ae7e8232652936a67fd792feabc --- .../react/uimanager/NativeViewHierarchyManager.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index b5939823a..1df358fad 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -12,6 +12,7 @@ package com.facebook.react.uimanager; import javax.annotation.Nullable; import javax.annotation.concurrent.NotThreadSafe; +import android.content.res.Resources; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.view.Menu; @@ -483,7 +484,7 @@ public class NativeViewHierarchyManager { } /** - * Returns the coordinates of a view relative to the entire phone screen (not just the RootView + * Returns the coordinates of a view relative to the window (not just the RootView * which is what measure will return) * * @param tag - the tag for the view @@ -499,6 +500,15 @@ public class NativeViewHierarchyManager { v.getLocationOnScreen(outputBuffer); + // We need to remove the status bar from the height. getLocationOnScreen will include the + // status bar. + Resources resources = v.getContext().getResources(); + int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android"); + if (statusBarId > 0) { + int height = (int) resources.getDimension(statusBarId); + outputBuffer[1] -= height; + } + // outputBuffer[0,1] already contain what we want outputBuffer[2] = v.getWidth(); outputBuffer[3] = v.getHeight();