0

Actually I set the textsize of a webview as follow:

WebSettings webSettings = mywebView.getSettings();
webSettings.setTextSize(WebSettings.TextSize.LARGEST);

I set the TextSize from WebSettings.TextSize.LARGEST to WebSettings.TextSize.SALLEST depending on settings in a options-gui, so the user can choose the Textsize.

Now the Question: But I think that WebSettings.TextSize.LARGEST is still too small on devices with a diagonal inch > 7.

So I want to scale the size a bit larger, but I don't know how to do this in a common way.

I mean I could set the DefaultFontSize of the webview directly, but I guess this will not scale correctly for all devices.

The question in code: I can't do:

 webSettings.setTextSize(WebSettings.TextSize.LARGEST * 1.5f);

Any hints how you do this ?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
mcfly soft
  • 11,289
  • 26
  • 98
  • 202
  • `webSettings.setTextSize` takes argument only as `TextSize` which is a `enum`. So you can not use a scale factor with `TextSize` . Have a look at [This thread](https://stackoverflow.com/questions/21694306/how-to-set-text-size-in-webview-in-android). – ADM Jan 12 '18 at 09:47
  • Yes I know. I am looking for a common solution to achieve the same. – mcfly soft Jan 12 '18 at 10:05

1 Answers1

0

webSettings.setTextSize is deprecated. I suggest you to try something like that :

int fontSize = webSettings.getDefaultFontSize();
int customFontSize = (int)(fontSize * 1.5);

webSettings.setDefaultFontSize(customFontSize);
Thomas Mary
  • 1,535
  • 1
  • 13
  • 24