Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] fix Android9 inaccurate ScreenHeight problem (#2536)
Browse files Browse the repository at this point in the history
* [Android] fix Android9 inaccurate SreenHeight problem
  • Loading branch information
katherine95s authored and YorkShen committed Jun 13, 2019
1 parent b07f49c commit 73c55cb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
Expand All @@ -36,6 +37,8 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;

import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
Expand Down Expand Up @@ -206,8 +209,17 @@ public static int getScreenHeight() {

public static int getScreenHeight(Context cxt) {
if(cxt!=null){
WindowManager wm;
Resources res = cxt.getResources();
mScreenHeight =cxt.getResources().getDisplayMetrics().heightPixels;
if(Build.VERSION.SDK_INT >= 28 && (wm = (WindowManager)cxt.getSystemService(Context.WINDOW_SERVICE)) != null
&& wm.getDefaultDisplay() != null){
Point size = new Point();
wm.getDefaultDisplay().getRealSize(size);
mScreenHeight = size.y;
}
else {
mScreenHeight = cxt.getResources().getDisplayMetrics().heightPixels;
}
if(WXEnvironment.SETTING_FORCE_VERTICAL_SCREEN){
mScreenWidth = res
.getDisplayMetrics()
Expand Down

0 comments on commit 73c55cb

Please sign in to comment.