From 08906e028a636b4c8566b368a9ec86cad1156c00 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Wed, 23 Nov 2022 17:41:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=89=E6=8C=89=E9=94=AE?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A8=A1=E5=BC=8F=E4=B8=8B=EF=BC=8C=E9=A6=96?= =?UTF-8?q?=E9=A1=B5Banner=E8=BF=9B=E5=8E=BB=E5=8F=AF=E8=83=BD=E7=BD=91?= =?UTF-8?q?=E9=A1=B5=E5=BA=95=E9=83=A8=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/activity/WebViewActivity.java | 11 +++++++---- .../yunbao/common/utils/JavascriptInterfaceUtils.java | 6 +++++- common/src/main/res/layout/activity_webview.xml | 5 +++++ 3 files changed, 17 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 c124caad8..7fa7dc562 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -27,6 +27,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.R; import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.utils.AndroidBug5497Workaround; +import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; @@ -67,14 +68,13 @@ public class WebViewActivity extends AbsActivity { btnEdit = (ImageView) findViewById(R.id.btn_edit); ft_title = (FrameLayout) findViewById(R.id.ft_title); v_spacing = (View) findViewById(R.id.v_spacing); + mWebView = findViewById(R.id.webView); AndroidBug5497Workaround.assistActivity(this); - mWebView = new WebView(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.topMargin = DpUtil.dp2px(1); - mWebView.setLayoutParams(params); - mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); - rootView.addView(mWebView); + // mWebView.setLayoutParams(params); + //mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { @@ -96,6 +96,9 @@ 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)"); } }); diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 43d876ad7..db761f3ef 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -484,7 +484,11 @@ public class JavascriptInterfaceUtils { Handler handler = new Handler(Looper.getMainLooper()); handler.post(() -> { ViewGroup.LayoutParams params = mWebView.getLayoutParams(); - params.height = DpUtil.dp2px(Integer.parseInt(height)); + if("-1".equals(height)){ + params.height=ViewGroup.LayoutParams.MATCH_PARENT; + }else { + params.height = Integer.parseInt(height); + } mWebView.setLayoutParams(params); mWebView.setVisibility(View.VISIBLE); }); diff --git a/common/src/main/res/layout/activity_webview.xml b/common/src/main/res/layout/activity_webview.xml index c67a6132b..da9a6f211 100644 --- a/common/src/main/res/layout/activity_webview.xml +++ b/common/src/main/res/layout/activity_webview.xml @@ -63,4 +63,9 @@ android:layout_height="3dp" android:progressDrawable="@drawable/bg_horizontal_progressbar" android:visibility="gone" /> + + \ No newline at end of file