我有一个由 Android 应用程序通过 Webview 组件显示的网页。
它决定更改字体大小,因此 16px 的文本具有 font-size=14px(当我用 weinre 检查元素时我可以看到它。它有 16px 但在计算样式中它有 14px)。
我根本不希望 Webview 决定什么更好。那么我该如何解决这个问题呢?
备注:在这种特定情况下,更改会导致文本不垂直对齐,因为更改后行高不会调整字体大小。这只是其中一种情况,我想阻止 Webview 更改 css 值。
最佳答案
这个问题似乎是由于 WebView 遵循系统字体大小设置(可以在以下位置更改:设置 > 显示 > 字体大小)。
在不同的地方提交了几个错误报告 ( for example )
In order to reproduce the problem you have to scale down the system font size to small or minimum.
...
Okay, I can repro if I change Settings > Display > Font size. It doesn't repro in Chrome, but then Chrome doesn't seem to respect "Font size" in the first place. I'm pretty busy right now, so it may be a while before I can investigate further.
尝试将您的系统字体大小设置为“小”或“中”并测试您的应用。
关于android - 防止 Android Webview 更改字体大小(计算样式),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16692817/