3

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?

BaluEdo
  • 119
  • 2
  • 11
  • Look at my solution on another similar post http://stackoverflow.com/questions/1973565/how-to-resize-a-android-webview-after-adding-data-in-it/25187094#25187094 – Chitranshu Asthana Aug 07 '14 at 16:01

4 Answers4

0

you might have to reload your webview with ie:

webview.loadUrl( "javascript:window.location.reload( true )" );
SunnySonic
  • 1,318
  • 11
  • 37
0

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.

Alex Kucherenko
  • 20,168
  • 2
  • 26
  • 33
0

You can use this:

myWebView.loadUrl("about:blank");
hmartinezd
  • 1,188
  • 8
  • 11
-2
private void reloadWebView() {
    // TODO Auto-generated method stub
    postDelayed(new Runnable() {
        @Override
        public void run() {
            clearView();
            reload();               
            myWebView.getSettings().setJavaScriptEnabled(true);
            requestLayout();
        }
    }, 10);
}
Rohit5k2
  • 17,948
  • 8
  • 45
  • 57
Venkatesh S
  • 5,466
  • 1
  • 25
  • 30