2013-03-27 73 views
-1

當我嘗試在機器人瀏覽器加載以下HTML頁面,圖像不重施膠根據如何根據不同的分辨率調整android webview中的圖像大小?

<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倍的圖像看起來很好。但文字與左邊對齊。 我在視口中缺少任何設置嗎?

P.S:僅在Kindle Fire HD和Kindle Fire Classic中出現文本對齊問題。

回答

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 
+0

我確實有應該不會佔據設備全寬的小圖像。 – Ads 2013-03-27 09:34:42

+1

怎麼樣一些百分比,然後像50%或東西 – 2013-03-27 09:35:15

+0

設置寬度=「50%」使圖像拉伸,因爲高度仍然是固定的 – Ads 2013-03-27 09:44:41

0

height =「600」width =「630」你已經設置了這個常量像素,所以圖像永遠不會調整大小。 您可以添加javascript,調整圖像大小。

相關問題