我希望能将WebView中使用的字体大小设置为特定像素大小。我的做法大致如下
<p style="font-size: 18px">Text</p>
然而,在不同的设备上,字体大小是不同的。有什么办法可以解决这个问题吗?
谢谢!
我希望能将WebView中使用的字体大小设置为特定像素大小。我的做法大致如下
<p style="font-size: 18px">Text</p>
然而,在不同的设备上,字体大小是不同的。有什么办法可以解决这个问题吗?
谢谢!
<meta name=\"viewport\" content=\"target-densitydpi=device-dpi\" />
setDefaultFontSize(int size)
方法来设置默认字体大小。
例如:myWebView.getSettings().setDefaultFontSize(20);
setInitialScale(int percentage)
方法来设置所需的百分比缩放,您可以尝试不同的百分比并查看哪个最合适。myWebView.setInitialScale(85);
setBuiltInZoomControls(boolean value)
方法允许/禁止用户使用默认缩放控件,以便他们根据自己的喜好进行缩放。myWebView.getSettings().setBuiltInZoomControls(true);
所有那些对我都不起作用,我需要做这个:
WebSettings settings = wv.getSettings();
if (Utils.hasIceCreamSandwich())
settings.setTextZoom( (int)(settings.getTextZoom() * 1.2));
else {
settings.setTextSize(WebSettings.TextSize.LARGER);
}