-1

In my application I am using webview. I want to change font size in webview,so I am doing it as:

WebSettings webSettings = webView.getSettings();
webSettings.setDefaultFontSize(25);

But it does not reflect text size change. I also tried using

loadUrl("javascript:(document.body.style.fontSize ='25pt');");

But still no luck. If I change .css file as

body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 25px;
color: #495A69;
background-color: #fff;
padding: 0 16px 16px;
}

Then it works. But I want to change Text size at runtime, Therefore I cant use this working css file. Any suggestion will be appreciated. Thanks in advance.

PPD
  • 5,660
  • 12
  • 52
  • 86

1 Answers1

6

Use this to zoom the text size

WebSettings settings = mWebView.getSettings();
 settings.setTextZoom(settings.getTextZoom() + 10);

or use

WebSettings settings = mWebView.getSettings();
    settings.setTextSize(WebSettings.TextSize.LARGER);
Fahim
  • 12,198
  • 5
  • 39
  • 57