-1

以下のHTMLページをAndroidブラウザに読み込もうとすると、画像が解像度に応じてサイズ変更されません

<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:テキストの配置の問題は、KindleFireHDとKindleFireClassicでのみ発生します。

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

height = "600" width = "630"この一定のピクセルを設定したので、画像のサイズが変更されることはありません。画像のサイズを変更するために、javascriptを追加できます。

于 2013-03-27T08:36:39.473 に答える
0

いくつかの目的のために、SheharyarNaseerによる以下の回答が役立ちます。

webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
于 2013-08-14T22:13:28.267 に答える