-1

当我尝试在 android 浏览器中加载以下 html 页面时,图像未根据分辨率重新调整大小

<html>
<header>
    <meta name="viewport"
        content="width=device-width,initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi" />
    <link rel="stylesheet" href="file:///android_asset/style.css"
        type="text/css">
</header>
<body>
    <p>This is a sample.</p>
    <br />
    <p>This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment This is a sample. this is a sample to test text alignment </p>
    <br />
    <img align="center" class="centeraligned"
        src="file:///mnt/sdcard/Android/data/com.sample.sample/sample.jpg"
        height="600" width="630" />
    <br />
</body>
</html>

如果我设置视口内容宽度 = 600 图像看起来很好。但文本左对齐。我错过了视口中的任何设置吗?

PS:文本对齐问题仅在 Kindle Fire HD 和 Kindle Fire Classic 中出现。

4

3 回答 3

1

我通常让图像填充 100% 的宽度。所以无论设备宽度高度是多少。像下面这样的东西会做

<img src="file:///mnt/sdcard/Android/data/com.sample.sample/sample.jpg" style="width:100%">

否则动态获取宽度、高度并在运行时更改图像

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document
$(window).width();   // returns width of browser viewport
$(document).width(); // returns width of HTML document
于 2013-03-27T08:45:49.020 回答
0

出于某些目的,Sheharyar Naseer 的以下回答将有所帮助:

webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
于 2013-08-14T22:13:28.267 回答
0

height="600" width="630" 你已经设置了这个恒定像素,所以图像永远不会调整大小。您可以添加 javascript 来调整图像大小。

于 2013-03-27T08:36:39.473 回答