Android--的PhoneGap /的WebView忽略视区meta标签? [英] Android-- PhoneGap/WebView ignores viewport meta tags?

查看:238
本文介绍了Android--的PhoneGap /的WebView忽略视区meta标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页,我想显示我的Andr​​oid设备上使用的PhoneGap(使用正常的WebView设置为appview)(从项目的资产目录中加载),但web视图完全忽略以下内容:

I have a webpage that I'm trying to display on my Android device (loaded from the assets directory of the project) using PhoneGap (which uses a normal WebView set as the "appview"), but the webview completely ignores the following:

<meta name = "viewport" content = "user-scalable=no,width=device-width" />

无论我在这一行设置(我已经明确地尝试设置缩放,设置宽/高像素等),该设备完全忽略它,使得该网站非常小,固定在左上屏幕 - 手角落。我可以用捏的手势(即使我明确禁用变焦在html code以上),即可放大,但我想在页面被放大的正常负载适合装置。

No matter what I set in this line (I've tried explicitly setting the zoom, setting the width/height in pixels, etc.), the device completely ignores it and renders the website very small and anchored to the upper left-hand corner of the screen. I can zoom in using the pinch gesture (even if I explicitly disable zoom in the html code above), but I want the page to be zoomed-in to properly fit the device on load.

这里的有趣的一点......如果我把完全相同的网站我的Web服务器上,并使用默认的浏览器我的测试设备上浏览到它,页面加载正常(缩放到合适大小的设备)。

Here's the interesting bit... If I put the exact same site on my web server and navigate to it using the default browser on my test device, the page loads properly (scaled to the right size for the device).

请帮忙。

感谢。

EDIT1:

我目前的设置是:

<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,target-densitydpi=device-dpi,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />

这也完全被忽略。

EDIT2:

下面是一些有趣的事情...

Here's something interesting...

<meta name="viewport" content="width=device-width, initial-scale=2.0, maximum-scale=2.0, user-scalable=no" />

以上线路调整页面中的仿真器的2倍还我的设备上没有改变什么(三星史诗运行2.2.1)。不过尽管如此,即使是2倍,该页面没有被缩放到仿真器的宽度......我不得不设置成类似初始规模= 2.5。

The above line scales the page to 2x in the emulator yet changes nothing on my device (Samsung Epic running 2.2.1). Still though, even at 2x, the page is not being scaled to the emulator's width... I'd have to set that to something like "initial-scale=2.5".

推荐答案

尝试在扩展DroidGap Java类的OnCreate()方法中添加以下两行。

Try adding the following two lines in the onCreate() method of the Java class that extends DroidGap.

this.appView.getSettings().setUseWideViewPort(true);
this.appView.getSettings().setLoadWithOverviewMode(true);

让我知道,如果你的视口的标签,现在开始工作。

Let me know if your viewport tag now begins to work.

这篇关于Android--的PhoneGap /的WebView忽略视区meta标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆