diff --git a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/DimensionsUtil.java b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/DimensionsUtil.java index 842e2eee872..22a6473dcd7 100644 --- a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/DimensionsUtil.java +++ b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/DimensionsUtil.java @@ -174,7 +174,10 @@ public static HippyMap getDimensions(int ww, int wh, Context context, if (context == null) { return null; } - DisplayMetrics windowDisplayMetrics = context.getResources().getDisplayMetrics(); + DisplayMetrics windowDisplayMetrics = PixelUtil.getMetrics(); + if (windowDisplayMetrics == null) { + windowDisplayMetrics = context.getResources().getDisplayMetrics(); + } DisplayMetrics screenDisplayMetrics = new DisplayMetrics(); screenDisplayMetrics.setTo(windowDisplayMetrics); WindowManager windowManager = (WindowManager) context diff --git a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/PixelUtil.java b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/PixelUtil.java index d2e9f249375..4bf17e1aee3 100644 --- a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/PixelUtil.java +++ b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/PixelUtil.java @@ -23,7 +23,7 @@ public class PixelUtil { private static DisplayMetrics sDisplayMetrics = null; - private static DisplayMetrics getMetrics() { + public static DisplayMetrics getMetrics() { if (sDisplayMetrics == null) { sDisplayMetrics = ContextHolder.getAppContext().getResources().getDisplayMetrics(); }