我改了一点,嵌套布局太多,如果是单一webview就比较好解决
mBinding.rvContentList.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
mBinding.rvContentList.loadUrl("javascript:App.resize(document.body.getBoundingClientRect().height)");
super.onPageFinished(view, url);
}
});
mBinding.rvContentList.addJavascriptInterface(this, "App");
@JavascriptInterface
public void resize(final float height) {
Log.e("TAG","promotion"+height);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
setWebViewHeight(DisplayUtils.dipToPixels(getActivity(), (int)height));
//Toast.makeText(getActivity(), height + "", Toast.LENGTH_LONG).show();
//此处的 layoutParmas 需要根据