我如何获得WVGA Android浏览器停止缩放我的图片? [英] How do I get the WVGA Android browser to stop scaling my images?

查看:145
本文介绍了我如何获得WVGA Android浏览器停止缩放我的图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设计一个HTML页面中的Andr​​oid浏览器中显示。考虑一个简单的示例页面:

I'm designing an HTML page for display in Android browsers. Consider this simple example page:

<html>
<head><title>Simple!</title>
</head>
<body>
<p><img src="http://sstatic.net/so/img/logo.png"></p>
</body>
</html>

它看起来只是罚款标准的HVGA手机(小320x480),但对华电国际的WVGA规格(480×800或为480x854),内置的浏览器会自动缩放图像了;它看起来丑陋。

It looks just fine on the standard HVGA phones (320x480), but on HDPI WVGA sizes (480x800 or 480x854) the built-in browser automatically scales the image up; it looks ugly.

我读过,我应该能够使用这个标记来强制浏览器停止缩放我的网页:

I've read that I should be able to use this tag to force the browser to stop scaling my page:

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />

......但所有这确实是禁止用户缩放(缩放按钮消失);它实际上并没有prevent结垢我的图像浏览器。调整比例因子(它们全部设置为2.0或0.5)没有任何作用的。

... but all that does is disable user scaling (the zoom buttons disappear); it doesn't actually prevent the browser from scaling my image. Adjusting the scale factors (setting them all to 2.0 or 0.5) has no effect at all.

如何强制WVGA浏览器停止缩放我的图片?

How can I force the WVGA browser to stop scaling my images?

推荐答案

嗯,通过在Android源$ C ​​$ C搜索找到了它。有一个新的Andr​​oid特有的<一个href="https://android.git.kernel.org/?p=platform/external/webkit.git;a=commit;h=f10585d69aaccf4c1b021df143ee0f08e338cf31">target-densityDpi"在视窗meta标签设置可用;!据我所知,这是完全无证,除了签入注释

Ah, found it by searching through the Android source code. There's a new Android-specific "target-densityDpi" setting available in the "viewport" meta tag; as far as I can tell, it's totally undocumented, except for the check-in comment!

添加DPI支持的WebView。

Add dpi support for WebView.

在视口元标记,你可以指定目标densityDpi。   如果没有指定,它使用默认,160dpi从今天开始。   然后在视口中标签规定的1.0的比例因子是指100%   在G1和150%的肖尔斯。如果将目标densityDpi来   设备dpi的时,则1.0的比例因子是指在两个G1和授斯100%

In the "viewport" meta tag, you can specify "target-densityDpi". If it is not specified, it uses the default, 160dpi as of today. Then the 1.0 scale factor specified in the viewport tag means 100% on G1 and 150% on Sholes. If you set "target-densityDpi" to "device-dpi", then the 1.0 scale factor means 100% on both G1 and Sholes.

实现Safari的window.devicePixelRatio和CSS媒体查询   设备象素比率

Implemented Safari's window.devicePixelRatio and css media query device-pixel-ratio.

您使用设备DPI和修改CSS的font-size和图像所以,如果   SRC取决于window.devicePixelRatio,你可以得到一个更好的页面   肖尔斯/激情。

So if you use "device-dpi" and modify the css for font-size and image src depending on window.devicePixelRatio, you can get a better page on Sholes/Passion.

下面是选择目标densityDpi列表。

Here is a list of options for "target-densityDpi".

设备DPI:使用设备自带的DPI为目标DPI。   低DPI:120DPI   中等DPI:160dpi,这也是默认的今天   高DPI:240dpi   :我们以70和400之间的任意数字作为一个有效的目标DPI

device-dpi: Use the device's native dpi as target dpi. low-dpi: 120dpi medium-dpi: 160dpi, which is also the default as of today high-dpi: 240dpi : We take any number between 70 and 400 as a valid target dpi.

这篇关于我如何获得WVGA Android浏览器停止缩放我的图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆