简体   繁体   English

webview(资产)不尊重设备宽度

[英]webview (assets) doesn't respect the device width

A month ago i did a simple webview that called a web page (php) in which there was this: 一个月前,我做了一个简单的Webview,它调用了一个网页(php),其中是这样的:

  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">

But now i've done the same thing but offline, viz the same files in the assets folder and i called them (index.php that includes header.php and footer.php) all in local), also the css file and js files using the webview function loadurl > "file:///android_asset/index.php". 但是现在我做了同样的事情,但离线,即在assets文件夹中查看了相同的文件,并在本地调用了它们(包括header.php和footer.php的index.php),还包括了css文件和js文件使用webview函数loadurl>“ file:///android_asset/index.php”。 I've tried on my device (samsung galaxy s2) and its ok, run, but it doesn't load the css or the header.php. 我已经尝试过我的设备(三星银河s2),可以正常运行,但它不会加载CSS或header.php。 SOmeone could help me? SOmeone可以帮助我吗? Thanks. 谢谢。

An Android device does not have a PHP intepreter / apacheserver inside to execute the PHP code and output the generated HTML. Android设备内部没有PHP解释器/ apacheserver来执行PHP代码并输出生成的HTML。 (So the include commands wont work) You have to include a plain HTML page in your assets folder or load a php page from a server... (not local) (因此,include命令将不起作用),您必须在资产文件夹中包含纯HTML页面,或从服务器加载php页面...(非本地)

To try it locally you can save the HTML page generated by the server from the online version with your browser and put that page in the assets folder. 要在本地尝试,您可以使用浏览器保存由服务器从在线版本生成的HTML页面,并将该页面放置在资产文件夹中。 But that is useless when your page is dynamic. 但是,当页面是动态的时,这是没有用的。

You need LocalServer installed on your Android for this issue, it is a easy job, just search for AndroPhp in GooglePLay install it on your Android, this way you have a LocalServer with MySQL db. 您需要在Android上安装LocalServer来解决此问题,这很容易,只需在GooglePL中搜索AndroPhp,然后将其安装在Android上即可,这样您就可以在LocalServer上安装MySQL数据库。

Then just copy your PHP project under www/ forlder ofcourse if you have db you shoul import in to MySQl on your Android. 然后,如果您有数据库,则只需将www.forlder.course下的PHP项目复制到Android上的MySQl中即可。

on Android side call call it than 127.0.0.1:80/yourproject 在Android旁叫比127.0.0.1:80/yourproject

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM