diff --git a/android/sdk/src/main/java/com/tencent/mtt/hippy/devsupport/inspector/model/DomModel.java b/android/sdk/src/main/java/com/tencent/mtt/hippy/devsupport/inspector/model/DomModel.java index de6401ec20f..33f7f9f8ec6 100644 --- a/android/sdk/src/main/java/com/tencent/mtt/hippy/devsupport/inspector/model/DomModel.java +++ b/android/sdk/src/main/java/com/tencent/mtt/hippy/devsupport/inspector/model/DomModel.java @@ -338,11 +338,12 @@ private int[] getRenderViewLocation(HippyEngineContext context, RenderNode rende View view = controllerManager.findView(renderNode.getId()); if (view != null) { view.getLocationOnScreen(viewLocation); - int statusBarHeight = ControllerManager.getStatusBarHeightFromSystem(); - viewLocation[1] = viewLocation[1] - statusBarHeight; - if (isTranslucentStatus(context)) { - // 沉浸式,需要加回状态栏的高度 - viewLocation[1] = viewLocation[1] + statusBarHeight; + HippyRootView rootView = getRootView(context); + if (rootView != null) { + int[] rootViewLocation = new int[2]; + rootView.getLocationOnScreen(rootViewLocation); + viewLocation[0] = viewLocation[0] - rootViewLocation[0]; + viewLocation[1] = viewLocation[1] - rootViewLocation[1]; } } else { return null; @@ -512,6 +513,11 @@ public JSONObject setInspectMode(HippyEngineContext context, JSONObject paramsOb return new JSONObject(); } + private static HippyRootView getRootView(HippyEngineContext context) { + int rootId = context.getDomManager().getRootNodeId(); + return context.getInstance(rootId); + } + /** * https://dom.spec.whatwg.org/#dom-node-nodetype */