How to change the FontSize in an Android WebView? How to change the FontSize in an Android WebView? android android

How to change the FontSize in an Android WebView?


I finally found it:-

WebSettings webSettings = webView.getSettings();

either setTextSize or

webSettings.setTextSize(WebSettings.TextSize.SMALLEST);

This one works too:-

webSettings.setDefaultFontSize(10);


It seems that nowadays prefered way, ie not depreciated is to change text zoom, like this:

WebSettings settings = mWebView.getSettings();settings.setTextZoom(90); // where 90 is 90%; default value is ... 100


This is what I use when I want to enable the user to change the text size / zoom in a WebView:

private WebView mWebView;// init web view and stuff like that ...private void textSmaller() {    WebSettings settings = mWebView.getSettings();    settings.setTextZoom(settings.getTextZoom() - 10);}private void textBigger() {    WebSettings settings = mWebView.getSettings();    settings.setTextZoom(settings.getTextZoom() + 10);}

On Actionbar Item click, I call either textSmaller() or textBigger() to change the text size.