Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the FontSize in an Android WebView?

How can you manually change the font size of a webview? e.g. When the page loads up in the webview the font size is like 24pt. and way too large for my android's screen. I've looked into the "websettings" but it seems that the two are not related.

Thanks

like image 960
Scott Avatar asked Sep 26 '10 00:09

Scott


People also ask

How do I change font size in Android XML?

Adding fonts to a TextView To set a font for the TextView , do one of the following: In the layout XML file, set the fontFamily attribute to the font file you want to access. Open the Properties window to set the font for the TextView .

Which is the correct syntax to change the font size in Android?

Click Ctrl + Shift + A. A new box will appear, search font there then you can see a lot of options then click on increase font size.

Can we change the text size programmatically?

To set Android Button font/text size, we can set android:textSize attribute for Button in layout XML file. To programmatically set or change Android Button font/text size, we can pass specified size to the method Button. setTextSize(specific_size).


1 Answers

I finally found it:-

WebSettings webSettings = webView.getSettings(); 

either setTextSize or

webSettings.setTextSize(WebSettings.TextSize.SMALLEST); 

This one works too:-

webSettings.setDefaultFontSize(10); 
like image 145
Scott Avatar answered Oct 08 '22 13:10

Scott