android scrollview 底部空白,Android ScrollView嵌套WebView出现底部空白问题
@JavascriptInterfacepublic void resize(final float height) {WebViewActivity.this.runOnUiThread(new Runnable() {@Overridepublic void run() {//Toast.makeText(getActivity(), height + "", Toast.LENGTH_LON
@JavascriptInterface
public void resize(final float height) {
WebViewActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
//Toast.makeText(getActivity(), height + "", Toast.LENGTH_LONG).show();
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams)mWebView1.getLayoutParams();
layoutParams.width = getResources().getDisplayMetrics().widthPixels;
layoutParams.height = (int) (height * getResources().getDisplayMetrics().density);
mWebView.setLayoutParams(layoutParams);
}
});
}
or
@JavascriptInterface
public void resize(final float height) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//Toast.makeText(getActivity(), height + "", Toast.LENGTH_LONG).show();
mWebView.setLayoutParams(new LinearLayout.LayoutParams(getResources().getDisplayMetrics().widthPixels, (int) (height * getResources().getDisplayMetrics().density)));
}
});
}
mWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
mWebView.loadUrl("javascript:App.resize(document.body.getBoundingClientRect().height)");
super.onPageFinished(view, url);
}
});
mWebView.addJavascriptInterface(this, "App");
更多推荐
所有评论(0)