2013-08-18 17 views
0

我正在開發基於android sdk和Eclipse的Phonegap應用程序。 只是採取了默認的代碼,並添加了<meta>的可擴展性,但它不允許我放大或縮小Android SGS2設備。 (沒有檢查了iPhone,因爲我沒有。)viewport - user-scalable = yes不起作用

的代碼如下:

<!DOCTYPE HTML> 
<html> 
    <head> 
    <meta name="viewport" 
     content="user-scalable=yes" /> 
    <!--<meta name="viewport" 
     content="user-scalable=yes, 
       initial-scale=1, 
       maximum-scale=4, 
       minimum-scale=1, 
       width=device-width, 
       height=device-height, 
       target-densitydpi=device-dpi" /> 
       --> 
    <title>First App</title> 
    <script src="cordova-2.2.0.js"></script> 
    <script> 
    function onLoad(){ 
      document.addEventListener("deviceready", 
       onDeviceReady, true); 
    } 
    function onDeviceReady(){ 
       navigator.notification.alert("PhoneGap is working!!"); 
    } 
    </script> 
    </head> 
    <body onload="onLoad();"> 
     <h1>Welcome to PhoneGap</h1> 
     <h2>Edit assets/www/index.html</h2> 
    </body> 
</html> 

回答

1

在Android上,你也使用loadURL這樣以後能放大?

super.loadUrl(Config.getStartUrl(), 80000); 

WebSettings settings = super.appView.getSettings(); 
settings.setBuiltInZoomControls(true); 
settings.setSupportZoom(true); 

就個人而言,除非您真的需要支持它,否則啓用縮放真的是在尋求麻煩。

0

嘗試使用代替用戶可擴展

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

它可以設置爲

用戶可擴展的屬性被翻譯成'用戶縮放'與下面的VA lue翻譯。

  1. yes和no分別被翻譯成'zoom'和'fixed'。
  2. 數≥1,≤-1號碼,設備寬度和設備高度被映射到「縮放」
  3. 號碼範圍< -1,1>,和未知值,映射到「固定」

見參考文獻:

W3C CSS Device Adaptation Spec: user-scalable

這:

http://dev.w3.org/csswg/css-device-adapt/

相關問題