在 Phonegap Android 应用程序中启用视口缩放无效 [英] Enabling viewport pinch-zoom in Phonegap Android application has no effect

查看:24
本文介绍了在 Phonegap Android 应用程序中启用视口缩放无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够使用我的 Android PhoneGap 应用上的视口设置打开和关闭双指缩放.

I need to be able to turn pinch-zoom on and off using the viewport setting on my Android PhoneGap app.

但是在使用 PhoneGap 时,我根本无法让视口影响捏合缩放.我无法在 PhoneGap 中打开双指缩放,但是当使用 Android Native 浏览器浏览网页时一切正常.

But I'm unable to get viewport to affect pinch-zooming at all when using PhoneGap. I cannot turn on Pinch-zoom in PhoneGap, but when browsing with the Android Native browser to the webpage everything works fine.

我花了很多时间寻找解决方案,但没有任何结果.

I have spent a lot of time searching for a solution, without any result.

我创建了一个非常简单的 index.html 用于测试,视口设置如下:

I created a very simple index.html for testing, having viewport setting like:

<meta name="viewport" content="user-scalable=yes" />

正如一些人所建议的,我也尝试过视口:

As some has suggested I have also tried the viewport:

<meta name="viewport" content="user-scalable=1" />

Android PhoneGap 的其他解决方案是启用 Android Native Pinch-Zoom,这里建议:放大android的phonegap但这对我不起作用,因为我需要能够从 javascript 控制捏缩放.IE.我需要能够使用 javascript 来更改视口设置,以控制何时可以使用捏合缩放(user-scalable=yes/user-scalable=no)

Other solutions for Android PhoneGap would be to enable Android Native Pinch-Zoom which have been suggested here: zoom in phonegap for android But this will not work for me, since I need to be able to control the pinch-zoom from javascript. I.e. I need to be able to use javascript to change the viewport setting, to control when pinch-zoom is available (user-scalable=yes / user-scalable=no)

请注意初始比例"和目标密度dpi"等其他视口设置似乎工作正常.例如设置 initial-scale=2 启动应用程序缩放.

Please observe that other viewport settings like "initial-scale" and "target-densitydpi" seems to work fine. For example setting initial-scale=2 starts the app zoomed.

(我目前正在 PhoneGap 1.4.1 和 HTC Desire HD Android 2.3.3 上测试双指缩放)

(I'm currently testing pinch-zoom on PhoneGap 1.4.1 and HTC Desire HD Android 2.3.3)

我开始觉得我漏掉了一些明显的东西,因为我发现关于类似问题的信息太少了...

I'm beginning to think I have missed something obvious, since I find so little information about similar problems...

最小的 index.html:

The minimal index.html:

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="user-scalable=yes" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Minimal AppLaud App</title>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
      <script type="text/javascript" charset="utf-8">

        var onDeviceReady = function() {
            document.getElementById("devready").innerHTML = "OnDeviceReady fired.";
        };

        function init() {
            document.addEventListener("deviceready", onDeviceReady, true);
        }   
      </script>  

  </head>
  <body onload="init();" id="stage" class="theme">
    <h2>Minimal AppLaud App</h2>
    <p> LOTS OF TEXT WHICH HAVE BEEN REMOVED HERE </p>

    <p><span id="devready">onDeviceReady not fired.</span></p>

  </body>
</html>

感谢您可能有的任何想法!

Appreciate any ideas that you might have!

推荐答案

我有完全相同的问题,除了测试不同的视口设置之外,我还尝试了以下建议:使用 Phonegap 和 jQUERY Mobile 在 Android 中捏合缩放 但我无法让它工作(在三星 Galaxy 上测试)SII,安卓 4.0.3).但是,其他人报告说使用链接中的提示成功进行了缩放.希望对你也有帮助!

I have exactly the same issue and besides testing different viewport settings, I have tried the suggestions from this: Pinch Zoom in Android with Phonegap and jQUERY Mobile but I can't make it work (testing on Samsung Galaxy SII, Android 4.0.3). However, others have reported successful pinch-zooming using the tips from the link. Hope it helps you too!

这篇关于在 Phonegap Android 应用程序中启用视口缩放无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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