From 29ddc68870adfcb58cd72a0c40b7b2e4ba2be686 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 6 Dec 2022 16:58:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9AWebViewActivity.java?= =?UTF-8?q?=20=E5=85=BC=E5=AE=B9=E4=B8=89=E6=8C=89=E9=94=AE=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/activity/WebViewActivity.java | 10 ++++++---- .../com/yunbao/common/utils/DeviceUtils.java | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java index 8856fff3a..0801887be 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -73,7 +73,7 @@ public class WebViewActivity extends AbsActivity { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.topMargin = DpUtil.dp2px(1); - // mWebView.setLayoutParams(params); + // mWebView.setLayoutParams(params); //mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); mWebView.setWebViewClient(new WebViewClient() { @Override @@ -96,9 +96,11 @@ public class WebViewActivity extends AbsActivity { if (url.contains("for")) { mWebView.loadUrl("javascript:goAnchorTab()"); } - //屏幕高度-ft_title的paddingTop - int height = DeviceUtils.getScreenHeight(mContext)-DpUtil.dp2px(24); - view.loadUrl("javascript:window.androidObject.setHeight("+height+",0,false)"); + //真实屏幕高度-(ft_title的高度+导航栏高度) + int height = DeviceUtils.getScreenRealHeight(mContext) - DpUtil.dp2px(72) - getCurrentNavigationBarHeight(mContext); + if (!navigationGestureEnabled(mContext)) { + view.loadUrl("javascript:window.androidObject.setHeight(" + height + ",0,false)"); + } } }); diff --git a/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java b/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java index 282fc17c2..40f76b35d 100644 --- a/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/DeviceUtils.java @@ -5,8 +5,10 @@ import android.app.ActivityManager; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.graphics.Point; import android.text.format.Formatter; import android.util.DisplayMetrics; +import android.view.WindowManager; /** * 设备通用类 @@ -36,6 +38,19 @@ public class DeviceUtils { return displayMetrics.heightPixels; } + /** + * 获取屏幕真实高度 + * + * @param activity activity + * @return 屏幕高度 + */ + public static int getScreenRealHeight(Activity activity) { + WindowManager service = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); + Point point = new Point(); + service.getDefaultDisplay().getRealSize(point); + return point.y; + } + /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) * @@ -63,7 +78,7 @@ public class DeviceUtils { public static String getVersionName(Context context) { try { PackageManager manager = context.getPackageManager(); - PackageInfo info = manager.getPackageInfo(context.getPackageName(),0); + PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); return info.versionName; } catch (Exception e) { e.printStackTrace(); @@ -81,6 +96,7 @@ public class DeviceUtils { am.getMemoryInfo(mi); return mi.lowMemory; } + public static String getMemory(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();