0

I find Android's web view behaviour strange when handling with css properties:

When displaying a web page that contains the following css properties: font-size and line-heightset to:

font-size: 20px;
line-height: 35px;

Android's webview changes the properties to:

font-size: 17.4px;
line-height: 30.45px;

Why?

2
  • It might be of an extra settings for font-size or zoom. Even in browser, general settings, accessibility settings, display settings, android general font-size settings etc. Commented Feb 28, 2018 at 9:13
  • Possible duplicate of How to set text size in WebView in android Commented Feb 28, 2018 at 9:22

2 Answers 2

2

I found answer:

Just webView must be to set text size to "NORMAL" in android. Like this:

webView.getSettings().setTextSize(WebSettings.TextSize.NORMAL);
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I was trying to find why this was happening. Btw Deprecated, Use webView.getSettings().setTextZoom(100); This will override the system font size on android webview to keep as normal.
0

Did you check page behavior in different resolutions? There might be defined @media rules in CSS, which change the style for different resolutions, for example:

@media screen and (min-width: 1024px) {
    p {
        font-size:20px;
        line-height:35px
    }
}

@media screen and (max-width: 1023px) {
    p {
        font-size:17.4px;
        line-height:30.45px
    }
}

Read more here.

2 Comments

Set this properties in element self style without defined media. In tablet and also in mobile chrome browser work true. but in application in mobile work wrong!
Try also here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.