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 7fa7dc562..8856fff3a 100644 --- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java @@ -98,7 +98,7 @@ public class WebViewActivity extends AbsActivity { } //屏幕高度-ft_title的paddingTop int height = DeviceUtils.getScreenHeight(mContext)-DpUtil.dp2px(24); - view.loadUrl("javascript:window.androidObject.setHeight("+height+",0)"); + view.loadUrl("javascript:window.androidObject.setHeight("+height+",0,false)"); } }); 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 db761f3ef..cc1d35230 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -476,8 +476,12 @@ public class JavascriptInterfaceUtils { } + /** + * 设置webView高度 + * @param useDp 是否用dp换算 + */ @JavascriptInterface - public void setHeight(String height, String width) { + public void setHeight(String height, String width,boolean useDp) { if ("0".equals(height)) { return; } @@ -487,7 +491,7 @@ public class JavascriptInterfaceUtils { if("-1".equals(height)){ params.height=ViewGroup.LayoutParams.MATCH_PARENT; }else { - params.height = Integer.parseInt(height); + params.height = useDp?DpUtil.dp2px(Integer.parseInt(height)):Integer.parseInt(height); } mWebView.setLayoutParams(params); mWebView.setVisibility(View.VISIBLE); diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index 98b264141..f89194d4d 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -192,7 +192,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { @Override public void onPageFinished(WebView view, String url) { - view.loadUrl("javascript:window.androidObject.setHeight(document.body.clientHeight,document.body.clientWidth)"); + view.loadUrl("javascript:window.androidObject.setHeight(document.body.clientHeight,document.body.clientWidth,true)"); if (listener != null) { listener.onShow(LiveHDDialogFragment.this.getDialog()); listener = null;