网页适用于所有Android设备

时间:2014-10-24 10:37:31

标签: android html css

我正在开发一个android项目,其中包含几个活动,每个活动都包含webviews.i使用html文件和css来实现这一点。但是我的网页在不同的android设备中是不同的。我不想要水平滚动,它必须自动适应所有设备。如果可能的话,任何人都可以找到解决方案吗?

我的webview.xml

   <WebView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:scrollbars="none"
    android:id="@+id/webView" />

我的java代码

      WebView web=(WebView)findViewById(R.id.webView);
      web.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
      web.loadUrl("file:///android_asset/www/cube.html");

我的cube.html文件

   <!DOCTYPE html>
   <html>
   <head>
  <meta charset="ISO-8859-1">
   <title>INTRODUCTION</title>
  <link rel="stylesheet" href="mystyles.css" type="text/css" />
  </head>
  <body>
 <div class="section">
  <h2>CUBE ROOT OF UNITY</h2>
  <p>As discussed in the previous section that the cube roots of unity are <mark class=          "bold">1, &#x03C9 and &#x03C9<sup> 2</sup></mark> where <mark class= "bold">&#x03C9    =e<sup>i2&#x3c0;/3</sup> = -1/2 + i &#x221A;3/2 and &#x03C9<sup>2</sup> = e<sup>i4&#x3c0;/3</sup> = -1/2 -i &#x221A;3/2.</mark> We shall now obtain cube roots of unity by an alternative method.</p>

</div>
</body></html>

和我的css文件

 h2 
 {
font-family: "Times New Roman",Times,serif;
color: #002671;
font-size: 23px;
font-weight: bold;
 border-bottom: 2px solid #CCC;
padding-bottom: 7px;
 margin: 24px 0px 0px;
 }

1 个答案:

答案 0 :(得分:0)

您可能想尝试将name="viewport" content="width=device-width, user-scalable=no"放在html文件的<meta> - 容器中。 ;)

这个shoud调整文档大小并防止用户缩放,所以最后你会有一个可以垂直滚动的文档。