修复心愿单高度异常问题

This commit is contained in:
zlzw 2022-11-24 13:45:59 +08:00
parent 32881d3f35
commit a2ad006a7e
3 changed files with 8 additions and 4 deletions

View File

@ -98,7 +98,7 @@ public class WebViewActivity extends AbsActivity {
} }
//屏幕高度-ft_title的paddingTop //屏幕高度-ft_title的paddingTop
int height = DeviceUtils.getScreenHeight(mContext)-DpUtil.dp2px(24); 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)");
} }
}); });

View File

@ -476,8 +476,12 @@ public class JavascriptInterfaceUtils {
} }
/**
* 设置webView高度
* @param useDp 是否用dp换算
*/
@JavascriptInterface @JavascriptInterface
public void setHeight(String height, String width) { public void setHeight(String height, String width,boolean useDp) {
if ("0".equals(height)) { if ("0".equals(height)) {
return; return;
} }
@ -487,7 +491,7 @@ public class JavascriptInterfaceUtils {
if("-1".equals(height)){ if("-1".equals(height)){
params.height=ViewGroup.LayoutParams.MATCH_PARENT; params.height=ViewGroup.LayoutParams.MATCH_PARENT;
}else { }else {
params.height = Integer.parseInt(height); params.height = useDp?DpUtil.dp2px(Integer.parseInt(height)):Integer.parseInt(height);
} }
mWebView.setLayoutParams(params); mWebView.setLayoutParams(params);
mWebView.setVisibility(View.VISIBLE); mWebView.setVisibility(View.VISIBLE);

View File

@ -192,7 +192,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
@Override @Override
public void onPageFinished(WebView view, String url) { 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) { if (listener != null) {
listener.onShow(LiveHDDialogFragment.this.getDialog()); listener.onShow(LiveHDDialogFragment.this.getDialog());
listener = null; listener = null;