问题
In my application I use a ScrollView. This ScrollView contain many Webview. I change the webview font size:
webView.getSettings().setTextSize(WebSettings.TextSize.LARGER);
after I change again the font size:
webView.getSettings().setTextSize(WebSettings.TextSize.SMALLER);
The font size is changing, but the webview layout height is not changing. The text is smaller and there are a big space. There are any method to this problem?
回答1:
you might have to reload your webview with ie:
webview.loadUrl( "javascript:window.location.reload( true )" );
回答2:
I had the same problem and fixed it using code:
private void reloadWebView() {
postDelayed(new Runnable() {
@Override
public void run() {
clearView();
requestLayout();
}
}, 10);
}
Call it method when You have finished zooming. It will refresh web view and recalculate it size.
回答3:
You can use this:
myWebView.loadUrl("about:blank");
回答4:
private void reloadWebView() {
// TODO Auto-generated method stub
postDelayed(new Runnable() {
@Override
public void run() {
clearView();
reload();
myWebView.getSettings().setJavaScriptEnabled(true);
requestLayout();
}
}, 10);
}
来源:https://stackoverflow.com/questions/12663083/webview-height-not-changing-after-resize-font-size