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 b5939823acf242..1df358fad1e11d 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 @@ 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 void measure(int tag, int[] outputBuffer) { } /** - * 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 void measureInWindow(int tag, int[] outputBuffer) { 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();